0

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

4

1 回答 1

0

尝试将端口从 587 更改为 25。Office365 smtp 服务器似乎更喜欢这个

(注意,我不知道这是否适用于 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
于 2015-05-17T14:44:03.637 回答