发送电子邮件时出错

时间:2013-07-16 01:14:09

标签: asp.net error-handling smtp email-validation

我已经编写了一个ASP.NET来每12小时发送一次SMTP邮件。它在我的办公室服务器上工作正常,但是当我在客户端服务器上运行该解决方案时,它显示错误“远程证书无效根据验证程序“。问题是什么?解决方案是什么?

1 个答案:

答案 0 :(得分:0)

已经有一些问题

(对要检查的内容有很好的反馈) The remote certificate is invalid according to the validation procedure

(代码在非prod上运行以获取过去的错误) "The remote certificate is invalid according to the validation procedure." using Gmail SMTP server

(附加信息)The remote certificate is invalid according to the validation procedure

如果那些不起作用

尝试在服务器上添加证书

  1. 将证书保存到您需要添加的计算机 证书也是。
  2. 开始 - >运行 - > MMC这将打开微软 管理控制台
  3. 转到文件 - >添加/删除管理单元...选择 可用管理单元中的证书:框,然后单击添加>
  4. 您将有三个选项(用户,服务,计算机),选择计算机 帐户并点击下一步>。单击完成关闭对话框,然后单击确定 关闭管理单元对话框
  5. 右键单击“受信任的根证书” 当局 - >所有任务 - >导入......
  6. 点击下一步>,浏览证书,然后点击下一步,直到对话框关闭然后你就可以了 成功添加了证书。
  7. 运行跟踪以查看错误消息

    将以下内容添加到您的web.config中。 (摘自here

    <system.diagnostics>
        <trace autoflush="true" />
                <sources>
                <source name="System.Net">
                        <listeners>
                <add name="System.Net"/>
                        </listeners>
                </source>
                <source name="System.Net.HttpListener">
                        <listeners>
                <add name="System.Net"/>
                        </listeners>
                </source>
        <source name="System.Net.Sockets">
                        <listeners>
                <add name="System.Net"/>
                        </listeners>
                </source>
        <source name="System.Net.Cache">
                        <listeners>
                <add name="System.Net"/>
                        </listeners>
                </source>
                </sources>
        <sharedListeners>
                <add
                 name="System.Net"
                 type="System.Diagnostics.TextWriterTraceListener"
                  initializeData="System.Net.trace.log"
                 traceOutputOptions = "ProcessId, DateTime"
                />
        </sharedListeners>
    <switches>
        <add name="System.Net" value="Verbose" />
        <add name="System.Net.Sockets" value="Verbose" />
        <add name="System.Net.Cache" value="Verbose" />
        <add name="System.Net.HttpListener" value="Verbose" />
    </switches>
    </system.diagnostics>
    

    这会让你仔细看看是什么问题。即。名称不匹配等。请务必将 initializeData =“System.Net.trace.log”更改为日志的位置,并确保网络服务具有r / w访问权限。