【发布时间】:2020-03-03 18:55:56
【问题描述】:
我正在尝试使用 C# 发送电子邮件 (SMTP),但有一个例外,“发送电子邮件失败”。
我在代码中启用了 SSL 并使用 465 端口(它是开放的)通过 system.net.mail 库将我的电子邮件发送到 Yahoo (smtp.mail.yahoo.com)。
try
{
string mass = " Hi, this is a compo team email to you for a verification code! Your verification code is: ''" + result + "'' You can enter this code to your compex for go ahead!!!";
string frommail = "<my mail is here>";
string tomail = emailtxt.Text;
string submail = "verification";
string smtptext = "smtp.mail.yahoo.com";
string passmail = "<my email password here> ";
MailMessage mail = new MailMessage(frommail, tomail, submail, mass);
SmtpClient client = new SmtpClient(smtptext);
client.Port = 465;
client.Credentials = new System.Net.NetworkCredential(frommail, passmail);
client.EnableSsl = true;
client.Send(mail);
MessageBox.Show("email sent", "log", MessageBoxButtons.OK);
/////email
}
catch (Exception exc)
{
MessageBox.Show(exc.Message);
}
我该如何解决?怎么了?
【问题讨论】:
-
完整的异常信息是什么?
-
只是发送邮件失败
-
您可能想尝试使用端口 587。
-
试过了。没有更改“发送邮件失败”再次@john
标签: c# smtp smtpclient mailing