.net 使用gmail smtp的SmtpAppender log4net
我用smtpAppender(gmail)配置了log4net。奇怪的是,当我在IIS 7.5上部署应用程序时,smtpAppender不工作 我尝试使用telnet命令测试与gmail smtp的连接。因此,我可以检查是否有任何内容被阻止,但测试工作正常 我的日志配置:.net 使用gmail smtp的SmtpAppender log4net,.net,asp.net-mvc-3,iis-7.5,log4net,log4net-configuration,.net,Asp.net Mvc 3,Iis 7.5,Log4net,Log4net Configuration,我用smtpAppender(gmail)配置了log4net。奇怪的是,当我在IIS 7.5上部署应用程序时,smtpAppender不工作 我尝试使用telnet命令测试与gmail smtp的连接。因此,我可以检查是否有任何内容被阻止,但测试工作正常 我的日志配置: 调试后,我发现以下异常: log4net:ERROR [SmtpAppender] ErrorCode: GenericFailure. Error occurred while sending e-mail notifi
调试后,我发现以下异常:
log4net:ERROR [SmtpAppender] ErrorCode: GenericFailure. Error occurred while sending e-mail notification.
System.Net.Mail.SmtpException: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at
at System.Net.Mail.MailCommand.CheckResponse(SmtpStatusCode statusCode, String response)
at System.Net.Mail.MailCommand.Send(SmtpConnection conn, Byte[] command, String from)
at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, SmtpFailedRecipientException& exception)
at System.Net.Mail.SmtpClient.Send(MailMessage message)
at log4net.Appender.SmtpAppender.SendEmail(String messageBody)
at log4net.Appender.SmtpAppender.SendBuffer(LoggingEvent[] events)
虽然这不是对你问题的直接回答,但我相信它可以帮助你发现问题。Log4net在静默中失败,这是经过设计的。为了获得错误信息,可以启用log4net调试
查看log4net常见问题解答问题出在gmail服务器端。Gmail服务器阻止了我的电子邮件,因为它怀疑我正在使用我的电子邮件帐户的地址。您需要配置允许从google developer portal中的应用发送电子邮件的权限。我使用了配置,但出现错误: 。。。需要身份验证 我发现,在谷歌账户的访问设置中,您需要启用以允许程序访问您的GMail
雅虎邮件也是如此,请参见谢谢克劳迪奥。在我启用log4net调试模式之后。我发现此异常:System.Net.Mail.SmtpException:SMTP服务器需要安全连接,或者客户端未通过身份验证。服务器响应为:需要5.5.1身份验证。。。