Добрый день, я новичок с помощью ASP.net и SMTP Mailerпочты SMTP с ASP.net Ошибка 5.5.1 Authentication Required
Heres мой вопрос, я всегда сталкиваются с этой ошибки, когда я отправить почту от моего местный и искал и попытался решения вокруг сети, но не так повезло, я надеюсь, что кто-то указать, какие коды мне нужно и где я столкнуться с этой errror
Message = "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"
Heres мой код:
protected void btnSendEmail_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.Value, txtName.Value);
smtpClient.Credentials = new System.Net.NetworkCredential("[email protected]", "password");
// You can specify the host name or ipaddress of your server
// Default in IIS will be localhost
smtpClient.Host = "smtp.gmail.com";
smtpClient.EnableSsl = true;
//Default port will be 25
smtpClient.Port = 25;
smtpClient.UseDefaultCredentials = false;
//From address will be given as a MailAddress Object
message.From = fromAddress;
// To address collection of MailAddress
message.To.Add("[email protected]");
message.Subject = txtSubject.Value;
// 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]");
// You can specify Address directly as string
message.Bcc.Add(new MailAddress("[email protected]"));
//Body can be Html or text format
//Specify true if it is html message
message.IsBodyHtml = false;
// Message body content
message.Body = txtaMessage.Value;
message.BodyEncoding = System.Text.Encoding.UTF8;
message.HeadersEncoding = System.Text.Encoding.UTF8;
// Send SMTP mail
smtpClient.Send(message);
lblSuccess.Text = "Email successfully sent.";
}
catch (Exception ex)
{
lblSuccess.Text = "Send Email Failed.";
}
}
попытайтесь добавить 'smtp.UserDefaultCreadential = true' и chage p ort до 587 – kulotskie
@kulotskie пробовал, что после прочтения этого, все еще не работает, такая же ошибка показывает –
Можете ли вы указать, что такое ошибка ?? – kulotskie