ahe*_*ang 3 .net c# asp.net visual-studio
我在这做错了什么?
private void SendMail(string from, string body)
{
string mailServerName = "plus.pop.mail.yahoo.com";
MailMessage message = new MailMessage(from, "aditya15417@yahoo.com", "feedback", body);
SmtpClient mailClient = new SmtpClient();
mailClient.Host = mailServerName;
mailClient.Send(message);
message.Dispose();
}
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
连接尝试失败,因为连接方在一段时间后没有正确响应,或者建立的连接失败,因为连接的主机无法响应209.191.108.191:25
您使用的是错误的服务器.您需要使用SMTP设置.
试试这个服务器:plus.smtp.mail.yahoo.com他们的网站将此主机记录为SSL.
private void SendMail(string from, string body)
{
string mailServerName = "plus.smtp.mail.yahoo.com";
int mailServerPort = 465;
string toAddress = "aditya15417@yahoo.com";
string subject = "feedback";
string username = "user";
string password = "password";
SmtpClient mailClient = new SmtpClient(mailServerName,
mailServerPort);
mailClient.Host = mailServerName;
mailClient.Credentials = new NetworkCredential(username,
password);
mailClient.EnableSsl = true;
using (MailMessage message = new MailMessage(from,
toAddress,
subject,
body))
mailClient.Send(message);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
830 次 |
| 最近记录: |