0

JMail (w3JMail v 4.5) を使用してメールを送信する Classic ASP で記述された古いアプリがいくつかあります。現在、ローカルの Microsoft Exchange サーバーから Office 365 に移行中です。JMail を使用して電子メールを送信するには、これらの古いアプリを引き続き使用する必要があります。

現在の ASP コード (Exchange サーバーを IP で参照):

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 のラッパーのようです。)

編集 - smtp.office365.com で試行およびテストされた CDO の例

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 に答える