2015-11-26 181 views
0

我有2个(假装)的电子邮件地址 - 雅虎和Hotmail: [email protected][email protected](不实)通过雅虎邮件发送失败

我试图从雅虎发送电子邮件到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") ="[email protected]" 
'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="[email protected]" 
Mail.To="[email protected]" 
Mail.TextBody="This is an email message." 

Mail.Send 
Set Mail = Nothing 

的错误信息是:

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

从@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") ="[email protected]" 
Mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") ="xxxx" 

Mail.Configuration.Fields.Update 

Mail.Subject="Email subject" 
Mail.From="[email protected]" 
Mail.To="[email protected]" 
Mail.TextBody="This is an email message." 

Mail.Send 
Set Mail = Nothing 
+0

尝试启用SSL(将'smtpusessl'选项设置为'True')。另外请确保您使用正确的服务器和端口。雅虎应该使用端口25来提交邮件似乎有点奇怪。通常会使用端口465或587。 –

+0

不知道哪些更改smtpusessl或465做了它,但现在它的工作。 –

回答

1

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

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

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

'Your UserID on the SMTP server 
Mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") ="[email protected]" 
'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 

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

+0

DOH!谢谢,但正如我所预料的那样,这些变化完全没有区别。 –

+0

感谢@Ansgar Wiechers我已经拿出了评论,我绝对相信虚拟数据('xxxx')没有问题,但它仍然给出相同的错误信息....不确定如何使用这里格式化所以这里是修改后的代码..... –

+0

不能发送修改后的代码---太长 –