无法向电子邮件发送消息
我在服务器上发送消息时遇到问题。但在我本地,我可以使用免费的 smtp 服务器向电子邮件发送消息。
也许存在防火墙或电子邮件策略不接受本地主机?
请指教..谢谢!
代码:
//send email
MailMessage objEmail = new MailMessage(new MailAddress(ConfigurationManager.AppSettings["emailAdd"].ToString()), new MailAddress(ConfigurationManager.AppSettings["emailAdd"].ToString()));
objEmail.Subject = "Test";
objEmail.Body = _Message;
objEmail.Priority = MailPriority.High;
SmtpClient SmtpMail = new SmtpClient();
SmtpMail.Host = "localhost";
SmtpMail.Send(objEmail);
错误:
System.Net.Mail.SmtpFailedRecipientException:邮箱不可用。服务器响应为:5.7.1 无法中继[电子邮件受保护] 在System.Net.Mail.SmtpTransport.SendMail(MailAddress发件人,MailAddressCollection收件人,字符串deliveryNotify,SmtpFailedRecipientException&异常) 在 System.Net.Mail.SmtpClient.Send(MailMessage 消息)
I having problem on sending message on the server. But in my local I can send message to the emails using the free smtp server.
Maybe there's a firewall or localhost is not accepted in the email policy?
Please advise.. thanks!
Code:
//send email
MailMessage objEmail = new MailMessage(new MailAddress(ConfigurationManager.AppSettings["emailAdd"].ToString()), new MailAddress(ConfigurationManager.AppSettings["emailAdd"].ToString()));
objEmail.Subject = "Test";
objEmail.Body = _Message;
objEmail.Priority = MailPriority.High;
SmtpClient SmtpMail = new SmtpClient();
SmtpMail.Host = "localhost";
SmtpMail.Send(objEmail);
Error:
System.Net.Mail.SmtpFailedRecipientException: Mailbox unavailable. The server response was: 5.7.1 Unable to relay for [email protected]
at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, SmtpFailedRecipientException& exception)
at System.Net.Mail.SmtpClient.Send(MailMessage message)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这个 博客文章回答了基本相同的问题。假设您通过 IIS SMTP 服务器发送,您可能需要修改中继限制以允许从您的 IP 地址进行中继。
This blog post answers basically the same question. Assuming you are sending through the IIS SMTP server, you may need to modify the Relay Restrictions to allow relaying from your IP address.
一些检查:
Few checks: