提问人:user2749297 提问时间:11/12/2023 最后编辑:Peppermintologyuser2749297 更新时间:11/12/2023 访问量:36
电子邮件发送不适用于通过 c 的 smtp 配置#
Email send not working with smtp configuration through c#
问:
我正在尝试通过带有 smtp 配置的 c# 代码发送电子邮件,但出现以下错误:
无法从传输连接读取数据:现有的 远程主机强行关闭了连接。
或者有时我会遇到这样的异常:
连接尝试失败,因为连接方没有 在一段时间后正确响应,或建立连接 失败,因为连接的主机无法响应
我的代码是:
SmtpMail oMail = new SmtpMail("TryIt");
oMail.From = SenderEmail;
oMail.To = TxtEmail.Value;
oMail.Subject = "Password Reset";
string body = "Hello " + ",";
body += "<br /><br />Please click the following link to reset password";
body += "<br /><a href = '" + RedirectRegPage + "'>Click here</a>.";
body += "<br /><br />Thanks";
oMail.HtmlBody = body;
SmtpServer oServer = new SmtpServer("mail.ServerName.com");
oServer.User = //User EMail
oServer.Password = // User EmailPassword
oServer.Port = 465;
EASendMail.SmtpClient oSmtp = new EASendMail.SmtpClient();
oSmtp.SendMail(oServer, oMail);
Session["Message"] = "MailSent";
电子邮件已通过我的 Outlook 成功发送。任何人都可以指导我在这里缺少什么,以便我可以得出一些解决方案。
答: 暂无答案
评论