首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Office365的ASP 4.5SMTP身份验证

Office365的ASP 4.5SMTP身份验证
EN

Stack Overflow用户
提问于 2015-05-15 21:27:49
回答 1查看 2.7K关注 0票数 0

我们有一些用经典的ASP编写的旧应用程序,它们使用JMail (w3JMail v4.5)发送邮件。我们正在从本地Microsoft Exchange服务器迁移到Office 365的过程中。我们需要这些旧的应用程序继续工作,使用JMail发送电子邮件。

我们当前的ASP代码(通过IP引用Exchange服务器):

代码语言:javascript
复制
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帐户的新版本:

代码语言:javascript
复制
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

我知道我们的用户名和密码是正确的,而且主机名也是正确的。

这取自日志输出:

代码语言:javascript
复制
AUTH LOGIN
 <- 504 5.7.4 Unrecognized authentication type
Authentication failed.
  smtp.office365.com:587 failed..
  No socket for server. ConnectToServer()

如何使用JMail设置身份验证类型?

EN

回答 1

Stack Overflow用户

发布于 2015-05-17 22:44:04

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

(注意,我不知道这是否适用于Jmail,但它确实适用于CDO,而且Classic ASP中的大多数第三方邮件组件似乎都是CDO的包装器。)

Edit - CDO示例,在smtp.office e365.com上试用和测试

代码语言:javascript
复制
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
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30260754

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档