【问题标题】:Cannot send email inspite of all ports being open and active尽管所有端口都处于打开和活动状态,但无法发送电子邮件
【发布时间】:2015-01-29 08:52:57
【问题描述】:

我有将电子邮件发送到用户在注册时提供的电子邮件 ID 的代码。它可以是我们公司的域 ID,也可以是任何其他域。

现在有 3 个不同的按钮可以调用三个不同的电子邮件页面。休假可以被批准、拒绝或取消。代码是通用的,只有男孩改变,结果通过改变状态字段的值反映在数据库中。

这是我正在使用的代码:

    try
        {
            string fromEmail = ConfigurationManager.AppSettings["EmailID"].ToString();
            string toEmail = lbl_emp_email.Text.Trim();                
            string bcc = Convert.ToString(lbl_logger_mailID.Text);

            MailMessage message = new MailMessage(fromEmail, toEmail);
            message.CC.Add("abcd@aaaa-india.org");
            message.Bcc.Add(new MailAddress(bcc));
            //send email to sender,the boss in this case.notify him he has approved a leave request

            message.Subject = lbl_subject.Text.Trim();
            message.Body = txt_mail_body.Text.Trim();
            SmtpClient smtp = new SmtpClient();
            smtp.Host = "smtp.aaaa-india.org";
            smtp.Send(message);
            Response.Write("<script type=\"text/javascript\">alert('Notification of leave approval sent.');</script>");
        }
        catch (Exception exce)
        {
            Response.Write("MAIL NOT SENT. AN ERROR OCCURRED." + exce.ToString());
        }


   <system.net>
<mailSettings>
  <smtp deliveryMethod="Network" from="support@aaaa-india.org" >
    <network defaultCredentials="false"
             enableSsl="true"
             host="smtp.aaaa-india.org"
             port="587"
             userName="support@aaaa-india.org"
             password="abcd"/>
  </smtp>
</mailSettings>
   </system.net>
   <appSettings>
<add key="EmailID" value="support@aaaa-india.org"/></appSettings>

根据我使用的端口号,我得到 3 个不同的错误。 由于我使用了上面的 587 端口,我收到以下错误:

    MAIL NOT SENT. AN ERROR OCCURRED.
    System.Security.Authentication.AuthenticationException: 
    The remote certificate is invalid according to the validation procedure. at 
    System.Net.Security.SslState.StartSendAuthResetSignal
    (ProtocolToken message, AsyncProtocolRequest asyncRequest, Exception exception)at  
    System.Net.Security.SslState.CheckCompletionBeforeNextReceive
    (ProtocolToken message, AsyncProtocolRequest asyncRequest) at 
     System.Net.Security.SslState.StartSendBlob
    (Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest) at 
    System.Net.Security.SslState.ProcessReceivedBlob
   (Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest) at 
    System.Net.Security.SslState.StartReadFrame
   (Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest) at 
    System.Net.Security.SslState.StartReceiveBlob
    (Byte[] buffer, AsyncProtocolRequest asyncRequest)

当我将端口号更改为 465 时,错误是:

   AN ERROR OCCURRED. System.Net.Mail.SmtpException: The operation has timed out. at 
   System.Net.Mail.SmtpClient.Send(MailMessage message) 
   at the line smtp.Send(message);

当我使用 25 端口时,错误再次出现:

    MAIL NOT SENT. AN ERROR OCCURRED.
    System.Security.Authentication.AuthenticationException: 
    The remote certificate is invalid according to the validation procedure. at 
    System.Net.Security.SslState.StartSendAuthResetSignal
    (ProtocolToken message, AsyncProtocolRequest asyncRequest, Exception exception) at 
    System.Net.Security.SslState.CheckCompletionBeforeNextReceive
   (ProtocolToken message, AsyncProtocolRequest asyncRequest) at 
    System.Net.Security.SslState.StartSendBlob
   (Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)

我已尝试在指定端口上打开与邮件服务器的 telnet 连接。它有效。 我什至检查了允许程序通过防火墙中的 HTTP 服务选项。

我还检查了防火墙是否阻止了任何内容,但事实并非如此。我手动启用了防火墙以允许所有与电子邮件相关的端口。我与管理员核实了任何阻止权限,但没有任何限制不允许我发送电子邮件。 作为最后的手段,我在我的计算机上安装了我公司的邮件客户端,并尝试在各种端口上使用 smtp。

一切正常。本网站除外。 请帮忙。

【问题讨论】:

  • SMTP 服务器是否支持 SMTP over SSL?
  • 我刚问过我的管理员,是的。我对此完全不知所措。

标签: c# asp.net email smtp


【解决方案1】:

在此处查看问题的答案 - 似乎类似: Getting "The remote certificate is invalid according to the validation procedure" when SMPT server has a valid certificate

我终于找到的答案是服务器上的SMTP服务没有使用与https相同的证书。

我在这里阅读的诊断步骤假设他们使用 相同的证书,每次我过去尝试过这个时,他们都有 完成,诊断步骤正是我为解决问题所做的 多次出现问题。

在这种情况下,这些步骤不起作用,因为正在使用的证书 是不同的,这种可能性是我从未有过的 遇到。

解决方案是从 服务器,然后将其作为受信任的证书安装在我的机器上,或者 为 SMTP 服务获取不同的有效/可信证书 服务器。目前由我们的 IT 部门负责管理 服务器来决定他们想要做什么。

【讨论】:

  • 我检查了,证书没有区别。我们检查了证书的每个细节,它是相同的。现在呢?
  • @avneesh 您已将证书作为可信证书添加到服务器上?
  • @avneesh 你可以做一些完全愚蠢的事情,就像一个健全的检查,并关闭证书验证。这样,如果它有效,您就知道问题出在证书上。 stackoverflow.com/questions/777607/…
  • 解决了!我删除了证书,然后再次从服务器复制它。我注意到我使用了错误的名称。我的服务器支持 mx。但是出现了一个新的问题。我无法将站点部署到内网。它显示错误-“无法访问远程服务器”,这是完全不可能的,因为站点只是通过服务器发送邮件!打败我什么可能是错的。对此有何建议?
  • @avneesh 最好在新问题中提问,而不是在此处提问,以便获得更多视图。还需要有关服务器设置的更多信息。
猜你喜欢
  • 2018-01-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-04-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多