c# - smtp.gmail.com - 无法从网站工作 - Hostgator 服务器
问题描述
我正在使用以下代码使用 google smtp 详细信息发送电子邮件。这段代码在我的本地机器上运行良好,但不能在网站/服务器上运行。
- 我正在使用
Hostgator
服务器,但我已经联系了他们,但没有运气。 - 我不想使用 Hostgator 服务来发送邮件。
using (SmtpClient smtp = new SmtpClient())
{
message.From = new MailAddress(("googleid"), "Test Label");
message.BodyEncoding = System.Text.Encoding.UTF8;
message.SubjectEncoding = System.Text.Encoding.Default;
smtp.Port = 587;
smtp.Host = smtp.gmail.com;
smtp.EnableSsl = true;
smtp.Credentials = new NetworkCredential(("googleid"), ("googlepass"));
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.Send(message);
}
解决方案
Hostgator 支持团队创建了 SPF 记录,这有助于解决问题。 https://support.google.com/a/answer/33786?hl=en
推荐阅读
- c - 当值为负时不要打印消息
- php - 使用 PHP 从任何 PDF 中检索字体列表
- node.js - MongoDB聚合返回空对象而不是null
- javascript - (React/Redux) Redux 操作中的异步问题
- jsf - 如何为 primefaces 字段集容器设置自定义高度?
- javascript - 如何在循环 JavaScript 中跳过一个数字?
- c# - 绑定到集合 Xamarin 中的索引
- javascript - 暂停 foreach 循环 unitl 事件发生,之后循环继续(JavaScript)
- javascript - Chrome 中不显示推送通知
- html - 绝对位置的中心下拉菜单