首页 > 解决方案 > smtp.gmail.com - 无法从网站工作 - Hostgator 服务器

问题描述

我正在使用以下代码使用 google smtp 详细信息发送电子邮件。这段代码在我的本地机器上运行良好,但不能在网站/服务器上运行。

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);
}

标签: c#email

解决方案


Hostgator 支持团队创建了 SPF 记录,这有助于解决问题。 https://support.google.com/a/answer/33786?hl=en


推荐阅读