【问题标题】:Sending email from Azure website, only timeouts, running out of ideas从 Azure 网站发送电子邮件,只有超时,没有想法
【发布时间】:2015-04-08 18:18:37
【问题描述】:

我们有一个尝试通过 SMTP 发送邮件的 Azure 托管网站。

我得到的只是超时,这是我的 POP 和 IMAP 设置以及代码。在网站下的 Azure 门户中 - 我需要在 Azure 网站设置中配置任何内容吗?

下面是我的 c# 代码...该代码使用从数据库中获取的以下值:

public bool Send(string sRecipient, string sSubject, string sBody)
{
    CompanyProvider obj = _db.GetCompanyProvider();

    if (!obj.EmailNotifications) 
        return true;


    MailMessage mail = new MailMessage();
    mail.To.Add(sRecipient);
    mail.From = new MailAddress(obj.SenderEmail);
    mail.Subject = sSubject;
    string Body = sBody;
    mail.Body = Body;
    mail.IsBodyHtml = true;
    SmtpClient smtp = new SmtpClient();
    smtp.Host = obj.SMTPHost;
    smtp.Port = obj.SMTPPort;
    smtp.Timeout = 8;
    smtp.UseDefaultCredentials = false;
    smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
    smtp.EnableSsl = true;
    smtp.Credentials = new System.Net.NetworkCredential(obj.SenderEmail, obj.SenderEmailPassword);// Enter senders User name and password
    //smtp.Credentials = new System.Net.NetworkCredential
        //(obj.SenderEmail.Substring(0, obj.SenderEmail.IndexOf('@')), obj.SenderEmailPassword);// Enter senders User name and password


    try
        {
            smtp.Send(mail);
            return true;
        }
        catch (Exception ex)
        {
            _db.writeToErrorLog(ex.ToString(), "Unable to send mail at this time");
            return false;
        }

}

}

【问题讨论】:

  • 你能提供完整的例外吗?

标签: asp.net-mvc azure


【解决方案1】:
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-10-19
  • 1970-01-01
  • 2010-11-22
  • 2012-01-12
  • 2015-09-20
  • 1970-01-01
  • 2021-11-28
相关资源
最近更新 更多