0

所以我有一个在 discountasp.net 上运行的 asp.net 服务器,无论出于何种原因,当我刚刚发布该网站的新版本时,它停止发送电子邮件。我尝试将代码更改回旧网站中的确切方式,但它不起作用。我尝试了许多其他解决方案均无济于事。这是旧代码:

 Dim message As New MailMessage
        message.IsBodyHtml = True
        message.From = New MailAddress("example@mydomain.com", "inquiry@mydomain.com")
        If Me.ddlSendTo.SelectedValue = 1 Then
            message.To.Add(New MailAddress("sales@mydomain.com"))
            message.Subject = "Sales Inquiry From mydomain.com"
        ElseIf Me.ddlSendTo.SelectedValue = 2 Then
            message.To.Add(New MailAddress("support@mydomain.com"))
            message.Subject = "Support Question From mydomain.com"
        End If

        Dim sb As New StringBuilder()
        sb.Append("The following message was sent from a user of our website as a request for more information.<br/><br/>")
        sb.Append("Here is the message they sent:<br/><br/>")
        sb.Append("Sender's Name: " & Me.txtSenderName.Text & "<br/>")
        sb.Append("Senders Email: <a href='mailto:" & Me.txtSenderEmail.Text & "'>" & Me.txtSenderEmail.Text & "</a><br/>")
        sb.Append("Company Name: " & Me.txtCompany.Text & "<br/>")
        sb.Append("Phone Number: " & Me.txtPhone.Text & "<br/><br/>")
        sb.Append("Subject: " & Me.txtSubject.Text & "<br/>")
        sb.Append("Message: " & Me.txtEmailMsg.Text)
        message.Body = sb.ToString()

        Try
            Dim client As New SmtpClient()
            client.Host = "localhost"
            client.Send(message)
        Catch ex As SmtpException
            Me.errors.InnerHtml = ex.Message & " local host message"
            Return
        End Try

这是我当前的迭代仍然无法正常工作:

Dim toEmail As String
    Dim subject As String
    If Me.ddlSendTo.SelectedValue = 1 Then
        If isTesting() Then
            toEmail = GetTesterEmail()
        Else
            toEmail = "sales@mydomain.com"
        End If

        subject = "Sales Inquiry From MyDomain.com"
    ElseIf Me.ddlSendTo.SelectedValue = 2 Then
        If isTesting() Then
            toEmail = GetTesterEmail()
        Else
            toEmail = "support@mydomain.com"
        End If
        subject = "Support Question From MyDomain.com"
    End If

    Dim sb As New StringBuilder()
    sb.Append("The following message was sent from a user of our website as a request for more information.<br/><br/>")
    sb.Append("Here Is the message they sent:<br/><br/>")
    sb.Append("Sender's Name: " & Me.txtName.Value & "<br/>")
    sb.Append("Senders Email: <a href='mailto:" & Me.txtEmail.Value & "'>" & Me.txtEmail.Value & "</a><br/>")
    sb.Append("Company Name: " & Me.txtCompany.Value & "<br/>")
    sb.Append("Phone Number: " & Me.txtPhone.Value & "<br/><br/>")
    sb.Append("Subject: " & Me.txtSubject.Value & "<br/>")
    sb.Append("Message: " & Me.txtMessage.Value)
    'message.Body = sb.ToString()
    Dim message As New MailMessage("postmaster@mydomain.com", toEmail, subject, sb.ToString())
    message.IsBodyHtml = True
    Try
        Dim client As New SmtpClient()
        client.Host = "smtp.mydomain.com"
        client.Port = 25
        client.Credentials = New System.Net.NetworkCredential("postmaster@mydomain.com", "password")
        client.Send(message)
    Catch ex As SmtpException
        Me.errors.Text = ex.Message & " local host message"
        Return
    End Try

我尝试离开网络凭据,离开端口,离开网络凭据上的@mydomain.com。没有任何作用

4

0 回答 0