Contact Us Page

2020-05-09 17:01发布

问题:

I have a Contact Us page that is not working. there is this error:

System.Net.Mail.SmtpException: Mailbox unavailable. The server response was: From domain must match authenticated domain at System.Net.Mail.MailCommand.CheckResponse(SmtpStatusCode statusCode, String response) at System.Net.Mail.MailCommand.Send(SmtpConnection conn, Byte[] command, MailAddress from, Boolean allowUnicode) at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddress Collection recipients, String deliveryNotify, Boolean allowUnicode, SmtpFailedRecipientException& exception) at System.Net.Mail.SmtpClient.Send(MailMessage message) at Pages_Public_Contact.btnSend_Click(Object sender, EventArgs e) in c:\Users\Vanguardo66\Documents\Visual Studio 2013\WebSites\TelerikWebSite2\Pages\Public\Contact.aspx.cs:line 27

and this is my code-behind:

if (Page.IsValid)
    {
        try
        {
            MailMessage mail = new MailMessage((Session["User"] == "Guest" ? txtFromUnknown.Text.Trim() : UserCheck.ReturnUserInfo(4)), "ops@gitamarine.com", "Visiting", txtText.Text.Trim());
            SmtpClient smtp = new SmtpClient("mail.gitamarine.com");
            smtp.EnableSsl = false;
            smtp.Credentials = new System.Net.NetworkCredential("website@gitamarine.com", "*********");
            smtp.Port = 2525;
            smtp.Send(mail);
        }
        catch (Exception ex)
        {
            lblAlert.Text = "Error: " + ex.ToString();
        }
    }

So I tried this but no luck!!! how does it work? I don't know!!! any way I am new to this please help.

回答1:

The error states the problem From domain must match authenticated domain you can't set the from address to the users email address, this would require an open relay mail server. Use the same from address that you used to do authentication



标签: c# asp.net