我们有一些用Classic ASP编写的旧应用程序使用JMail(w3JMail v 4.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设置身份验证类型??
答案 0 :(得分:0)
尝试将端口从587更改为25. Office365 smtp服务器似乎更喜欢这个
(NB我不知道这是否适用于Jmail,但它确实适用于CDO,而Classic ASP中的大多数第三方邮件组件似乎都是CDO的包装器。)
编辑 - CDO示例,使用smtp.office365.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 = Nothing