无法将邮件发送到 SMTP 服务器。传输错误 0x80040217

Couldn't send message to SMTP server. Transport Error 0x80040217

我在使用 gmail 通过 asp 发送邮件时收到此错误,我已经使用了端口 465、587 和 25,结果相同

昏暗的邮件 将电子邮件 2 暗淡为字符串 暗淡的 urls 为字符串

Dim mail 
dim email2 as string
dim urlms as string
    

mail = CreateObject("CDO.Message")    
urlms = "http://schemas.microsoft.com/cdo/configuration/" 
mail.Configuration.Fields.Item(urlms  & "sendusing") = 2 'enviar usando port
mail.Configuration.Fields.Item(urlms  & "smtpserver") = "smtp.gmail.com"
mail.Configuration.Fields.Item(urlms  & "smtpserverport") = 465
mail.Configuration.Fields.Item(urlms  & "smtpusessl") = True
mail.Configuration.Fields.Item(urlms  & "smtpconnectiontimeout") = 60
mail.Configuration.Fields.Item(urlms + "smtpauthenticate") = 1
mail.Configuration.Fields.Item(urlms + "sendusername") = "" 'login
mail.Configuration.Fields.Item(urlms + "sendpassword") = "" 'password

mail.Configuration.Fields.Update

mail.Send

//
// MessageId: CDO_E_LOGON_FAILURE
//
// MessageText:
//
// The transport was unable to log on to the server.
//
#define CDO_E_LOGON_FAILURE              0x80040217L

另外为什么要用plus来连接三个配置项。

您的代码将所有内容调暗两次。它将事物变暗为字符串。

您没有使用 Set 创建对象。

我怀疑你的代码运行时产生错误。

它对我自己的邮件服务器很有用,但它对 Gmail 却失败了,我不知道为什么....

无论如何,我也试过没有加号来连接但也没有用,最后我用了这个:

Dim ObjSendMail
Set ObjSendMail = CreateObject("CDO.Message") 
     
'This section provides the configuration information for the remote SMTP server.
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'Send the message using the network (SMTP over the network).
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") ="mail.yoursite.com"
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465 ' or 587
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
     
' Google apps mail servers require outgoing authentication. Use a valid email address and password registered with Google Apps.
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'basic (clear-text) authentication
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") ="somemail@yourserver.com" 'your Google apps mailbox address
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") ="yourpassword" 'Google apps password for that mailbox
     
ObjSendMail.Configuration.Fields.Update
     
ObjSendMail.To = "someone@someone.net"
ObjSendMail.Subject = "this is the subject"
ObjSendMail.From = "someone@someone.net"
     
' we are sending a text email.. simply switch the comments around to send an html email instead
'ObjSendMail.HTMLBody = "this is the body"
ObjSendMail.TextBody = "this is the body"
     
ObjSendMail.Send
     
Set ObjSendMail = Nothing 

http://somee.com/DOKA/DoHelpTopics.aspx?docode=false&thnid=102

对我的服务器来说非常有用,但对 gmail 不起作用。

注意:消息显示登录错误。请确保名称和密码正确。

Set emailObj      = CreateObject("CDO.Message")
emailObj.From     = "dc@gail.com"

emailObj.To       = "dc@gail.com"

emailObj.Subject  = "Test CDO"
emailObj.TextBody = "Test CDO"

Set emailConfig = emailObj.Configuration
msgbox emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") 
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing")    = 2  
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1  
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpusessl")      = true 
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername")    = "YourUserName"
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword")    = "Password1"
emailConfig.Fields.Update

emailObj.Send

If err.number = 0 then Msgbox "Done"

如果您在 Google 帐户中使用两步验证,那么您需要更改设置,选择 "Enable Less Secure Apps" 或生成 16 个字符的应用密码,您需要在您的代码,而不是您实际的 gmail 密码。 https://www.google.com/settings/security/lesssecureapps