我们有一些用经典的ASP编写的旧应用程序,它们使用JMail (w3JMail v4.5)发送邮件。我们正在从本地Microsoft Exchange服务器迁移到Office 365的过程中。我们需要这些旧的应用程序继续工作,使用JMail发送电子邮件。
我们当前的ASP代码(通过IP引用Exchange服务器):
Set objMail = Server.CreateObject("JMail.Message")
objMail.MailServerUserName = "domain\username"
objMail.MailServerPassWord = "password"
objMail.ContentType = "text/plain"
objMail.From = "name1@domain.co.uk"
objMail.AddRecipient "name2@domain.co.uk"
objMail.Subject = "Test"
objMail.Body = "Test"
objMail.Send("10.10.10.1")
Set objMail = Nothing这是我必须尝试使用我们的Office 365帐户的新版本:
Set objMail = Server.CreateObject("JMail.Message")
objMail.Silent = True
objMail.Logging = True
objMail.MailServerUserName = "name1@domain.co.uk"
objMail.MailServerPassword = "password"
objMail.ContentType = "text/plain"
objMail.From = "name1@domain.co.uk"
objMail.AddRecipient "name2@domain.co.uk"
objMail.Subject = "Test"
objMail.Body = "Test"
If objMail.Send("smtp.office365.com:587") Then
Response.Write "Sent an e-mail..."
Else
Response.Write( "ErrorCode: " & objMail.ErrorCode & "<br />" )
Response.Write( "ErrorMessage: " & objMail.ErrorMessage & "<br />" )
Response.Write( "ErrorSource: " & objMail.ErrorSource & "<br /><br />" )
Response.Write( "" & objMail.Log & "<br /><br />" )
End If
Set objMail = Nothing我知道我们的用户名和密码是正确的,而且主机名也是正确的。
这取自日志输出:
AUTH LOGIN
<- 504 5.7.4 Unrecognized authentication type
Authentication failed.
smtp.office365.com:587 failed..
No socket for server. ConnectToServer()如何使用JMail设置身份验证类型?
发布于 2015-05-17 22:44:04
尝试将端口从587更改为25。Office365 smtp服务器似乎更喜欢这样
(注意,我不知道这是否适用于Jmail,但它确实适用于CDO,而且Classic ASP中的大多数第三方邮件组件似乎都是CDO的包装器。)
Edit - CDO示例,在smtp.office e365.com上试用和测试
Dim objMail, iConfg, Flds
Set objMail = Server.CreateObject("CDO.Message")
Set iConfg = Server.CreateObject("CDO.Configuration")
Set Flds = iConfg.Fields
With Flds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.office365.com"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "me@mydomain.com"
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "mypassword"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = true
.Update
End With
objMail.Configuration = iConfg
objMail.To = Request.Form("recipient")
objMail.From = "me@mydomain.com"
objMail.Subject = "Email form submission"
objMail.TextBody = Request.Form("message")
objMail.Send
Set objMail = Nothinghttps://stackoverflow.com/questions/30260754
复制相似问题