私はIIS6からIIS7にWebサイトを移行しています。私はすべてが動作しているが、サイトは電子メールを送信しません。IIS7で電子メールを送信できません
私は、ピックアップフォルダにテキスト文書をドロップすると配信されるので、サーバーが電子メールを正しく処理していることを確認しましたが、コードでメッセージを送信しようとするとエラーが発生するか、
SMTP仮想サーバーは標準設定でセットアップされています。
問題のWebサイトが4.0 Framework、統合アプリケーションプールを使用していますが、私はApplicationPoolIdentityとNetworkServiceの両方を試してみました。サイトのSMTPモジュールでは、127.0.0.1のSMTPサーバー、localhostとサーバーのドメイン名をすべてポート25で試しました。
私はVBSとクラシックASPを使って電子メールを送信してきましたasp.netとして
私は非常に基本的なスクリプトを試してきました。たとえば、
vb.netです。このコードはエラーは表示されませんが、メッセージは送信されず、イベントビューアには何も見つかりませんでした。
Public Shared errorEmailTo As String = System.Configuration.ConfigurationManager.AppSettings("errorEmailTo")
Public Shared errorEmailFrom As String = System.Configuration.ConfigurationManager.AppSettings("errorEmailFrom")
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim email As String = "This is a test email."
show.Text = "To: " + System.Configuration.ConfigurationManager.AppSettings("errorEmailTo") + "<br/>"
show.Text += "From: " + System.Configuration.ConfigurationManager.AppSettings("errorEmailFrom") + "<br/>"
Try
Helper.SendError(email)
show.Text += "No Error"
Catch ex As Exception
show.Text += "Error: " + ex.Message
End Try
End Sub
Public Shared Sub SendError(ByVal strBody As String)
Dim Email As New System.Net.Mail.MailMessage(errorEmailFrom, errorEmailTo)
Email.Subject = "Error Message"
Email.Body = strBody
Dim mailClient As New System.Net.Mail.SmtpClient()
mailClient.UseDefaultCredentials = True
mailClient.EnableSsl = False
Try
mailClient.Send(Email)
Catch ex As Exception
End Try
End Sub
VBSこのコードは、「トランスポートはサーバーに接続できませんでした」というエラーを返します。新しいほぼ同じコードブロック以外のものは見つかりませんでした。
strSMTPFrom = "[email protected]"
strSMTPTo = "[email protected]"
strSMTPRelay = "localhost"
strTextBody = "Body of your email"
strSubject = "Subject line"
Set oMessage = CreateObject("CDO.Message")
oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = strSMTPRelay
oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
oMessage.Configuration.Fields.Update
oMessage.Subject = strSubject
oMessage.From = strSMTPFrom
oMessage.To = strSMTPTo
oMessage.TextBody = strTextBody
oMessage.Send
従来のASPでは、同じエラーメッセージが表示されます。
<%
Dim sch, cdoConfig, cdoMessage
sch = "http://schemas.microsoft.com/cdo/configuration/"
Set cdoConfig = CreateObject("CDO.Configuration")
With cdoConfig.Fields
.Item(sch & "sendusing") = 2 ' cdoSendUsingPort
.Item(sch & "smtpserver") = "localhost"
.Item(sch & "smtpserverport") = 25
.update
End With
Set cdoMessage = CreateObject("CDO.Message")
With cdoMessage
Set .Configuration = cdoConfig
.From = "[email protected]"
.To = "[email protected]"
.Subject = "Email test"
.TextBody = "This is the test body of the email"
.Send
End With
Set cdoMessage = Nothing
Set cdoConfig = Nothing
%>
これらのコードブロックを実際の例として示した例を見てきましたが、何が間違っていますか?
実際のSMTPサーバーでアドレスを指定してみてください。または、正しい[配信方法]を設定してください(https://msdn.microsoft.com/en-us/library/system.net.mail.smtpclient.deliverymethod(v = vs.110).aspx) – mason
私が知っていたすべての送信メールアドレスにmailer_email_addとパスワードが必要です。 –
電子メールは魔法ではありません。それはどこかに行かなければならない。あなたのSMTPサーバがどこにあるかあなたのネットワーク管理者に尋ねてください。 – mason