SMTP服务器需要安全连接或客户端未经过身份验证。服务器响应为:5.5.1需要身份验证。

问题描述:

先生,为什么会出现这个问题。

****************

MailMessage mailMsg = new MailMessage();


mailMsg.From =新邮件地址(txtemail.Text);



mailMsg.To.Add( xxxxxxxxxxxxxx@gmail.com);



mailMsg.IsBodyHtml = true;



mailMsg.Subject = Enquery详细信息;



mailMsg.Body =Enquery Details+名称:+ txtname.Text +
电子邮件 - 地址:+ txtemail.Text +

地点:+ txtplace.Text +
移动设备:+ txtmobile.Text +

签入:+ txtdatecheckin.Text +

签出:+ txtcheckout.Text +
消息:+ TextBox2.Text;



SmtpClient smtp = new SmtpClient(smtp.gmail.com,587);



mailMsg.Priority = MailPriority.Normal;



smtp.Credentials = new System.Net.NetworkCredential(x xxxxx@gmail.com,xxxxxxxxxxxxxxxxxxxxxx);



smtp.Timeout = 25000;



smtp.EnableSsl = true;



smtp.Send(mailMsg);

************* *************

此代码在本地主机上工作正常,但上传到服务器时出错: -

SMTP服务器需要安全连接或客户端未经过身份验证。服务器响应是:5.5.1







需要验证。了解更多信息

描述:执行当前Web请求期间发生了未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。



异常详细信息:System.Net.Mail.SmtpException:SMTP服务器要求安全连接或客户端未经过身份验证。服务器响应为:5.5.1需要身份验证。了解更多信息



来源错误:





第40行:smtp .EnableSsl = true;

第41行:

第42行:smtp.Send(mailMsg);

第43行:}

第44行:}

先生请帮助我。

sir why this problem occures.
****************
MailMessage mailMsg = new MailMessage();

mailMsg.From = new MailAddress(txtemail.Text);

mailMsg.To.Add("xxxxxxxxxxxxxx@gmail.com");

mailMsg.IsBodyHtml = true;

mailMsg.Subject = "Enquery Details";

mailMsg.Body = "Enquery Details" + "Name:" + txtname.Text + "
Email - address :" + txtemail.Text + "
Place :" + txtplace.Text + "
Mobile:" + txtmobile.Text + "
Check In:" + txtdatecheckin.Text + "
Check Out:" + txtcheckout.Text + "
Message:" + TextBox2.Text;

SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);

mailMsg.Priority = MailPriority.Normal;

smtp.Credentials = new System.Net.NetworkCredential("xxxxxx@gmail.com", "xxxxxxxxxxxxxxxxxxxxxx");

smtp.Timeout = 25000;

smtp.EnableSsl = true;

smtp.Send(mailMsg);
**************************
this code is working fine in local host but upload to server get error:-
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1



Authentication Required. Learn more at
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Net.Mail.SmtpException: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at

Source Error:


Line 40: smtp.EnableSsl = true;
Line 41:
Line 42: smtp.Send(mailMsg);
Line 43: }
Line 44: }
sir plz help me thans.

所以看一下这个消息:如果它尝试的话就不能更清楚了:

So look at the message: it couldn't be any clearer if it tried:
The SMTP server requires a secure connection or the client was not authenticated.

请检查您的用户ID,检查密码。



它拒绝了您的请求,因为它不喜欢其中一个......

So check your user ID, check your password.

It's rejecting your request because it doesn't like one of them...