【问题标题】:SMTP works in Visual Studio but not when uploading to production IIS ServerSMTP 在 Visual Studio 中有效,但在上传到生产 IIS 服务器时无效
【发布时间】:2015-04-13 21:11:36
【问题描述】:

我已将其缩小为 IIS 的问题。我正在使用 system.net.mail 发送电子邮件。它们在我的本地机器上工作,但是当我将它们发布到我的 IIS8 Server 2012 服务器时,电子邮件无法发送。

Try
        Dim mailMessage As New MailMessage("test@test.com", Me.ddlApprovers.SelectedValue)
        mailMessage.Subject = "TEST"

        mailMessage.Body = "TEST"

        Dim smtpClient As New SmtpClient(My.Settings.SMTP, 25)

        smtpClient.Send(mailMessage)
    Catch ex As Exception
        Me.lblAlertText.Text = "An error send email has occured. Contact your system administrator."
        ScriptManager.RegisterStartupScript(Me, Me.GetType(), "LaunchAlertPopup", "$(function() { AlertMessage(); });", True)
    End Try

我已经下载了一个 SMTP 测试工具,通过它可以正常发送电子邮件,所以它必须是 IIS 中的这个网站的问题。

【问题讨论】:

  • 发生的确切异常是什么?没有这些信息,就无法为您提供帮助

标签: c# .net email iis smtp


【解决方案1】:

许多 ISP 阻止端口 25。尝试通过 465 或 587 发送。还值得检查可能阻止任何这些端口的任何防火墙规则。

我们只能假设您为 SMTP 客户端使用了有效的主机名。这需要存在,否则您的消息将永远无法发送。

【讨论】:

    猜你喜欢
    • 2023-03-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多