本文介绍了(SMTP EXCEPTION)SMTP服务器需要安全连接或客户端未经过身份验证。服务器响应为:5.7.0必须首先发出STARTTLS命令。 jm5sm6473157pbc.1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
protected void btnSendmail_Click(object sender, EventArgs e)
{
// System.Web.Mail.SmtpMail.SmtpServer is obsolete in 2.0
// System.Net.Mail.SmtpClient is the alternate class for this in 2.0
SmtpClient smtpClient = new SmtpClient();
MailMessage message = new MailMessage();
try
{
MailAddress fromAddress = new MailAddress(txtEmail.Text, txtName.Text);
// You can specify the host name or ipaddress of your server
// Default in IIS will be localhost
smtpClient.Host = "localhost";
//Default port will be 25
smtpClient.Port = 25;
smtpClient.Host = "smtp.gmail.com";
//From address will be given as a MailAddress Object
message.From = fromAddress;
// To address collection of MailAddress
message.To.Add("[email protected]");
message.Subject = "Feedback";
// CC and BCC optional
// MailAddressCollection class is used to send the email to various users
// You can specify Address as new MailAddress("[email protected]")
message.CC.Add("[email protected]");
//message.CC.Add("[email protected]");
//Body can be Html or text format
//Specify true if it is html message
message.IsBodyHtml = false;
// Message body content
message.Body = txtMessage.Text;
smtpClient.UseDefaultCredentials=false;
smtpClient.Credentials = new NetworkCredential("[email protected]", "xxxxxxxxxxxxxx");
// Send SMTP mail
smtpClient.Send(message);
lblStatus.Text = "Email successfully sent.";
}
catch (System.Net.Mail.SmtpException ex)
{
Response.Write(ex.ToString());
}
catch (Exception ex)
{
lblStatus.Text = "Send Email Failed.<br>" + ex.Message;
}
}</br>
推荐答案
smtpclient.EnableSsl = true;
所有最佳
All the Best
smtpClient.EnableSsl = true;
它说服务器不支持安全连接
it say Server doesnot support secure connections
这篇关于(SMTP EXCEPTION)SMTP服务器需要安全连接或客户端未经过身份验证。服务器响应为:5.7.0必须首先发出STARTTLS命令。 jm5sm6473157pbc.1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!