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 を使用して認証タイプを設定するにはどうすればよいですか?