小总结: CDO.Message只能调用IIS的SMTP服务进行发信, 而Jmail可以调用很多类型的SMTP服务,包括IIS的SMTP服务。 =======================================================
1。关于CDO.Message参数设置: ----------------------------------------- sURL = "http://schemas.microsoft.com/cdo/configuration/" Set myMail=CreateObject("CDO.Message") myMail.BodyPart.CharSet="GB2312" myMail.BodyPart.ContentTransferEncoding="base64" myMail.From=classEmail '发送人 myMail.Sender=className '发送人名字 myMail.Subject="欢迎您成为" & className &"的新成员!" '标题 myMail.To=email '收信人地址 myMail.HTMLBody=mailBody
'发送方式:1是本机发送(其余三个参数无视),2是远程server发送(如果不需要验证,则用户名和密码无视) '如果你的空间的smtp服务不在web服务器上,请把以下注释去掉。 'myMail.Configuration.Fields.Item(sURL & "sendusing")=2 'myMail.Configuration.Fields.Item(sURL & "smtpserver") = smtpServer 'myMail.Configuration.Fields.Item(sURL & "sendusername") = smtpUser 'myMail.Configuration.Fields.Item(sURL & "sendpassword") = smtpPassword 'myMail.Configuration.Fields.Update
myMail.Send set myMail=nothing ------------------------------------------- 试验纪录:
CDO ----------------------------------- 参数1,使用本机smtp,通过
参数2,使用本机smtp The server rejected the sender address. The server response was: 501 5.5.4 Invalid Address
参数2,使用远程smtp服务器 (验证或不验证都是此错,应该是smtp服务器拒绝了,如果从web空间上执行则正常通过) The server rejected the sender address. The server response was: 501 unacceptable mail address
Jmail ------------------------------------ 远程smtp,验证,All is OK!!
本机smtp,由于不需要验证,代码里不能有验证的部分,否则出错。 =======================================================================
2。使用Jmail组件,调用IIS的SMTP服务进行发信,报错: ----------------------------------------------------- The message was undeliverable. All servers failed to receive the message .execute() { Trying server mail:127.0.0.1 <- 220 wahaha Microsoft ESMTP MAIL Service, Version: 5.0.2195.6713 ready at Sun, 26 Mar 2006 17:55:44 +0800 -> EHLO wahaha <- 250-wahaha Hello [127.0.0.1] 250-AUTH GSSAPI NTLM LOGIN 250-AUTH=LOGIN 250-SIZE 2097152 250-PIPELINING 250-DSN 250-ENHANCEDSTATUSCODES 250-8bitmime 250-BINARYMIME 250-CHUNKING 250-VRFY 250 OK -> MAIL FROM: <- 250 2.1.0 aaa@xx.com....Sender OK -> RCPT TO:xxx@yyy.com <- 550 5.7.1 Unable to relay for xxx@yyy.com -> DATA <- 554 5.5.2 No valid recipients Error: 554 5.5.2 No valid recipients ----------------------------------------------------- 注意红色部分,搜索了半天,不是代码问题,是IIS的SMTP服务不允许中继。
解决方法: 打开IIS管理器,右键SMTP虚拟服务--属性--中继, 添加127.0.0.1到允许列表里,确定。重起SMTP服务即可。
另外注意一点,一般IIS的SMTP服务都不需要身份验证,所以Jmail发信的代码里 不要有: 'Jmail.MailServerUserName = smtpUser 'SMTP验证帐号 'Jmail.MailServerPassword = smtpPassword 'SMTP认证密码 有就会报验证失败。
====================以下是关于中继的一篇文章================================= 550 or 553 Relay Denied Error (Windows)Document ID: 1593HQ Issue: When sending mail in Eudora, the error message "550 Relay Denied" is given by the SMTP server (Eudora may display "This message is not acceptable to your SMTP server. The message is not sendable until the recipient has been changed.") and mail cannot go out. Solution: Most Internet Service Providers restrict access to their outgoing mail servers to prevent SPAM from being sent through their mail servers. If you are getting the "550 Relay Denied" error message, the outgoing mail server cannot verify who you are and will not allow you to send mail. Mail Relay is when you connect to a mail server on another domain and try to send mail. For example, if you are connected to the internet through AT&T and then try to send mail using Earthlink's mail server. Historically, mail relay was fine - SMTP servers did not check to see who was sending the mail and would simply pass the mail on, no questions asked. But unsolicited bulk mailers (SPAMMERS) have taken advantage of this to send huge volumes of mail with fraudulent return addresses (so as not to be traced) - which slows down the server for the paying customers who have the right to use it and slows down servers everywhere with all that junk mail. One of the ways to restrict access to an outgoing mail server is to verify that the computer is on the ISP's local network. When you dial your modem and connect to your ISP, your computer is given an IP address that identifies you as being a part of that ISP's network. If you have two ISP's and dial up to one and then connect to the other's mail server, it may prevent you from relaying mail because your computer is not identified as being on the local network for the provider whose mail server you are sending through. For example, if you connect to the internet with AT&T and try to send mail using Earthlink's mail server, you will get a 550 error. To fix this, you should try to use the SMTP server for the provider you have used to dial up and connect to the Internet. Another way to restrict access is to insist on a local domain return address. If you connect to the mail server for "domain.com" it may only allow you to send mail that is from "username@domain.com" -- if you try to send from another account and have the return address of "username@anotherdomain.com" it may restrict you from relaying to another server. For example, if you connect to the internet using domain.com, it will check to make sure that your email says it's from domain.com . To fix this, change the "From" field under Tools: Options and make sure that your Return Address matches. Note: Relay does not apply to sending to users local to the SMTP server. If you connect to "domain.com" and send mail to "user@domain.com" you are not relaying. Often this is confusing because it means that you can send a test message to yourself, but cannot send mail to other people on the Internet. Eudora 6 introduces SMTP Relay Personality that allows you to use send mail from one Personality but send it in a way that is acceptable to the SMTP server. You can learn more about this feature at http://www.eudora.com/techsupport/kb/2107hq.html . Keywords: EPWIN, UNACCEPTABLE, RELAY, RELAYING, SENDING, 550, 553, 535
|