通过Yahoo发送邮件失败

时间:2015-11-26 11:20:17

标签: email vbscript

我有2个(假装)电子邮件地址 - Yahoo和Hotmail: myyahoo@yahoo.com和myhotmail@hotmail.com(不是真实的)

我正在尝试从Yahoo发送一封电子邮件给Hotmail。

基本上我已经尝试了其他几种电子邮件地址配置 - 都没有成功。

我已经挖掘了几天,下面的代码(从here修改)应该可行,但它没有。

'Sending an email using a remote server
Set Mail = CreateObject("CDO.Message")

'This section provides the configuration information for the remote SMTP server.

'Send the message using the network (SMTP over the network).
Mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

Mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") ="smtp.mail.yahoo.com"
Mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

'Use SSL for the connection (True or False)
Mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False

Mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60

'If your server requires outgoing authentication, uncomment the lines below and use a valid email address and password.
'Basic (clear-text) authentication
Mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
'Your UserID on the SMTP server
Mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") ="myyahoo@yahoo.com"
'Mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") ="password"

Mail.Configuration.Fields.Update

'End of remote SMTP server configuration section

Mail.Subject="Email subject"
Mail.From="myyahoo@yahoo.com"
Mail.To="myhotmail@hotmail.com"
Mail.TextBody="This is an email message."

Mail.Send
Set Mail = Nothing

错误消息是:

  

第32行   Char 1
  错误服务器拒绝了发件人地址。服务器响应为530 5.7.1需要验证
  代码8004020E
  来源(null)

在@Ansgar Wiechers的回复之后我修改了代码。 我绝对相信虚拟数据(xxxx)是有效的,但我仍然得到与上面相同的结果错误....

Set Mail = CreateObject("CDO.Message")

Mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
Mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") ="smtp.mail.yahoo.com"
Mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
Mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False
Mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
Mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
Mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") ="xxxx@yahoo.com"
Mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") ="xxxx"

Mail.Configuration.Fields.Update

Mail.Subject="Email subject"
Mail.From="xxxx@yahoo.com"
Mail.To="xxxx@hotmail.com"
Mail.TextBody="This is an email message."

Mail.Send
Set Mail = Nothing

1 个答案:

答案 0 :(得分:1)

错误消息相当不言自明。远程服务器拒绝了您的邮件,因为它没有正确验证:

  

错误服务器拒绝了发件人地址。服务器响应为530 5.7.1 需要身份验证

在您的代码中,提供密码的语句已被注释掉:

'Your UserID on the SMTP server
Mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") ="myyahoo@yahoo.com"
'Mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") ="password"

因此您尝试使用您的邮件地址和空密码进行身份验证。取消注释该行并确保密码正确。

此外,您可能需要启用SSL:

Mail.Configuration.Fields.Item ("http://sche...tion/smtpusessl") = True

和/或将端口更改为465(smtps):

Mail.Configuration.Fields.Item ("http://sche...tion/smtpserverport") = 465

或587(提交):

Mail.Configuration.Fields.Item ("http://sche...tion/smtpserverport") = 587

取决于服务器提供的邮件提交方式。