smtp。live不能发送电子邮件-错误:邮箱不可用。服务器响应为:5.7.3请求操作中止;用户没有通过身份验证

时间:2021-03-11 18:16:06

I saw all the other pages on * that were about this problem and tried them but none of them worked.

我看到了所有关于这个问题的关于*的页面,并尝试了它们,但没有一个成功。

im doing a website as a project for school, and I want the users to send an e-mail for them to report problems in, but it always gives me that error.

我在做一个网站作为学校的项目,我想让用户给他们发电子邮件,让他们报告问题,但它总是给我这个错误。

this is my code:

这是我的代码:

    protected void Sendbtn_Click(object sender, EventArgs e)
    {
    try
      {

        MailMessage mailMessage = new MailMessage();
        mailMessage = new     MailMessage("user@hotmail.com","my@hotmail.com");           
        mailMessage.Subject = "Problem from Gamer's Utopia";
        mailMessage.Body = this.msgtxt.Text;
        SmtpClient smtpClient = new SmtpClient(" smtp.live.com");

        smtpClient.EnableSsl = true;
        smtpClient.Send(mailMessage);
        Response.Write("E-mail sent!");
      }
    catch (Exception ex)
      {
        Response.Write("Could not send the e-mail - error: " + ex.Message);
      }
    }

I tried using authentication with username and password but it didnt work - unless I did it incorrectly.

我尝试使用用户名和密码进行身份验证,但没有成功——除非我做错了。

4 个解决方案

#1


0  

add authenticated NetworkCredential

添加验证NetworkCredential

System.Net.NetworkCredential smtpUser = new System.Net.NetworkCredential("admin@hotmail.com", "password");
smtpClient.Credentials = smtpUser;

#2


0  

You need to set SmtpClient Credentials, for example

例如,您需要设置SmtpClient凭证。

smtpClient.Credentials = new System.Net.NetworkCredential("youremail@hotmail.com", "password"); 

check below answer for sample code:

以下是样本代码的答案:

https://*.com/a/9851590/2558060

https://*.com/a/9851590/2558060

#3


0  

Change your code according to this!!! It will perfectly work!!!

根据这个改变你的代码!!!它将完全工作! ! !

using (MailMessage mail = new MailMessage()) {

使用(MailMessage = new MailMessage()) {

            SmtpClient client = new SmtpClient("smtp.live.com");
            mail.From = new MailAddress("from address");


            mail.Subject = "";

string message = "";

字符串消息= " ";

            mail.Body = message;
            try
            {
                mail.To.Add(new MailAddress("To Address"));

            }
            catch
            {

            }

            client.Credentials = new System.Net.NetworkCredential("smtp.live.com", "password");
            client.EnableSsl = true;


            try
            {
                System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; };
                client.Send(mail);
                mail.To.Clear();

            }
            catch (Exception ex)
            {

            }

        }

#4


-1  

From your sender account, view the email inbox and say it is you to allow the third party to send emails.

从你的发件人帐户,查看电子邮件收件箱,并说它是你允许第三方发送电子邮件。

#1


0  

add authenticated NetworkCredential

添加验证NetworkCredential

System.Net.NetworkCredential smtpUser = new System.Net.NetworkCredential("admin@hotmail.com", "password");
smtpClient.Credentials = smtpUser;

#2


0  

You need to set SmtpClient Credentials, for example

例如,您需要设置SmtpClient凭证。

smtpClient.Credentials = new System.Net.NetworkCredential("youremail@hotmail.com", "password"); 

check below answer for sample code:

以下是样本代码的答案:

https://*.com/a/9851590/2558060

https://*.com/a/9851590/2558060

#3


0  

Change your code according to this!!! It will perfectly work!!!

根据这个改变你的代码!!!它将完全工作! ! !

using (MailMessage mail = new MailMessage()) {

使用(MailMessage = new MailMessage()) {

            SmtpClient client = new SmtpClient("smtp.live.com");
            mail.From = new MailAddress("from address");


            mail.Subject = "";

string message = "";

字符串消息= " ";

            mail.Body = message;
            try
            {
                mail.To.Add(new MailAddress("To Address"));

            }
            catch
            {

            }

            client.Credentials = new System.Net.NetworkCredential("smtp.live.com", "password");
            client.EnableSsl = true;


            try
            {
                System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; };
                client.Send(mail);
                mail.To.Clear();

            }
            catch (Exception ex)
            {

            }

        }

#4


-1  

From your sender account, view the email inbox and say it is you to allow the third party to send emails.

从你的发件人帐户,查看电子邮件收件箱,并说它是你允许第三方发送电子邮件。