我们有一些用 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 设置身份验证类型..?