Saturday, February 04, 2012
 
The best way to analyze your logs! Minimize
 Log4Net Mail archive   

The Log4Net mailing list is a great source of information about using log4Net, in this forum we collect all the messages in the log4net user list and some selected threads from the developer list.

Subject: RE: Error while sending Mail to smtp.gmail.com
Prev Next
You are not authorized to post a reply.

Author Messages
Sree

07/17/2009 9:08 AM  

à I’m able to successfully send mail using .net code through gmail by enabling SSL.

 

But using log4net its given error:

 

My Code in app.config file:

 

     <appender name="SmtpAppender" type="log4net.Appender.SmtpAppender">

      <to value="myusername@gmail.com" />

      <from value=" myusername@gmail.com " />

      <subject value="test logging message" />

      <smtpHost value="smtp.gmail.com" />

      <authentication value = "Basic" />

      <username value = " myusername@gmail.com " />

      <password value = "mypassword" />

      <ssl value ="true"/>

      <port value ="465"/>

      <bufferSize value="512" />

      <lossy value="true" />

      <evaluator type="log4net.Core.LevelEvaluator">

        <threshold value="ALL"/>

      </evaluator>

      <layout type="log4net.Layout.PatternLayout">

        <conversionPattern value="%newline%date [%thread] %-5level %logger [%property{NDC}] - %message%newline%newline%newline" />

      </layout>

    </appender>

 

 

 

Getting error:

 

log4net:ERROR [SmtpAppender] Error occurred while sending e-mail notification.

System.Net.Mail.SmtpException: The operation has timed out.

   at System.Net.Mail.SmtpClient.Send(MailMessage message)

   at log4net.Appender.SmtpAppender.SendEmail(String messageBody)

   at log4net.Appender.SmtpAppender.SendBuffer(LoggingEvent[] events)

 

 

 

I tried using STARTTLS protocol also…which gave me an error with authentication and so….

 

 

 

Please help me out….I deadly need it work it down…

 

Best regards,

Sree

Radovan Raszka

07/17/2009 10:13 AM  
According to documentation, there is no Ssl property for SmtpAppender. According source code it is named EnableSsl, so repair your config.
But I'm not sure if it helps...
Radovan Raszka

 

Sree

07/17/2009 10:23 AM  

 

Fyi: I added the property taking reference from http://logback.qos.ch/manual/appenders.html

 

If I remove the ssl property I get the following error:

 

log4net:ERROR [SmtpAppender] 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.7.0 Must issue a STARTTLS command first. b39sm3288571rvf.8

   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)

 

Best regards,

Sree

 

Radovan Raszka

07/17/2009 12:59 PM  
do not delete ssl property, but rename it to enablessl.
Radovan

 

Sree

07/17/2009 1:08 PM  

log4net:ERROR XmlHierarchyConfigurator: Cannot find Property [enablessl] to set object on [log4net.Appender.SmtpAppender]

 

getting the above error

 

Best regards,

Sree

 

Radovan Raszka

07/17/2009 1:23 PM  
strange, this property exists in source code taken from source repository. But doesn't exist in binary distribution (even there is no ssl property!), so try to get current sources from repository, compile and try again....
Radovan

 

Sree

07/20/2009 9:50 AM  

No this also didn’t work out…

 

Radovan Raszka

07/20/2009 9:45 PM  
Works for me without any configuration exception. I had only to change port to 25, why you are trying 465? My config:

<appender name="SmtpAppender" type="log4net.Appender.SmtpAppender">

<to value="raszka@hasam.cz" />

<from value="myusername@gmail.com " />

<subject value="test logging message" />

<smtpHost value="smtp.gmail.com" />

<authentication value = "Basic" />

<username value = "username" />

<password value = "mypassword" />

<enablessl value ="true"/>

<port value ="25"/>

<bufferSize value="512" />

<lossy value="false" />

<evaluator type="log4net.Core.LevelEvaluator">

<threshold value="ALL"/>

</evaluator>

<layout type="log4net.Layout.PatternLayout">

<conversionPattern value="%newline%date [%thread] %-5level %logger [%property{NDC}] - %message%newline%newline%newline" />

</layout>

</appender>

RR
Sree

07/21/2009 11:01 AM  

 

But I’m getting error:

 

 

A first chance exception of type 'System.InvalidOperationException' occurred in log4netTests.exe

log4net:ERROR [SmtpAppender] 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.7.0 Must issue a STARTTLS command first. 22sm14461822wfd.8

   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)

 

 

Do I need to do any other specific settings..

 

Please help me out…and I really Thank for ur responses…

 

Best regards,

Sree

 

 

 

Radovan Raszka

07/21/2009 11:51 AM  
One more idea - is there any antivirus / firewall software on the computer you are doing your tests? It can block communication - I had to switch outgoing mail checking off somewhere in the past....
RR

 

Sree

07/21/2009 12:30 PM  

 

I’ve disabled the windows firewall & also the antivirus software but sill got the below error…no change… L

 

 

Best regards,

Sree

 

Radovan Raszka

07/22/2009 9:48 AM  
Try my testing project on your machine (I think lossy and buffer settings has significant effect whether message is really sent or not, but always I get no exception). If it works, search for differences in your project (notice I am using log4net build from repository, it probably will not work with release available on download page).
If not - your computer probably made god angry.
RR

 

Sree

07/22/2009 11:38 AM  

I found a change:

 

Wrt UserName & Password – what is the value we need to specify?

 

Till now I was using my gmail username & password..

 

Might be that is the mistake I’m doing…

 

Please let me know..

 

Best regards,

Sree

 

Radovan Raszka

07/22/2009 12:05 PM  
use username & password you are using when accesing you mail through web interface. Username should be your alias from email addres. If address is your.name@gmail.com, username should be your.name. But I don't know, if it is always true.
RR
Sree

07/22/2009 12:14 PM  

L it didn’t work out…

 

Sree

07/22/2009 12:32 PM  

Ya its working. I tried out with my credentials in ur code…

 

Thanks a lot…It was really a great help.

 

Best regards,

Sree

 

Sree

07/23/2009 12:24 PM  

The issue was with the log4net.dll.. I downloaded from their site.

 

After I used the dll from ur project in my project it worked out.

 

From where I could get this valid dll..please let me know.

 

Best regards,

Sree

 

Ron Grabowski

07/30/2009 3:04 AM  
My suggestion would be to get email sending working using SmtpClient. There's nothing wrong with writing your own Appender. Here's one that I use for sending low volume ERROR and FATAL messages in a Medium Trust hosting environment:

    public class MediumTrustSmtpAppender : AppenderSkeleton
    {
        public string From { get; set;}
        public string To { get; set;}
        public string Subject { get; set;}
        public string Host { get; set;}

        protected override void Append(LoggingEvent loggingEvent)
        {
            MailMessage mailMessage = new MailMessage(From, To, Subject, RenderLoggingEvent(loggingEvent));
            SmtpClient smtpClient = new SmtpClient(Host);
            smtpClient.Send(mailMessage);
        }
    }

You are not authorized to post a reply.
Forums > Log4Net > Log4Net Mail archive > RE: Error while sending Mail to smtp.gmail.com



ActiveForums 3.7

 

 

 

 

 

 

 

 

Log4Net Dashboard

Log analysis and monitoring made easy!

Log4Net Dashboard is a log viewer that can read log statements from a variety of logging output targets.

You can download a free developer version.

  

Check it out!

On the demonstration site you can try it  with live data.demo.l4ndash.com - Try Log4Net Dashboard with live data

The mail archive is a copy of all the mail sent to the mail address: log4net-user@logging.apache.org, organized as a forum.

If you would like to participate in the mail list, send a mail to log4net-user-subscribe@logging.apache.org.

More information about the mailing list is available on: http://logging.apache.org/log4net/support.html

 

A complete topic list is available and can be viewed here (warning, it takes some time to load)

 

Copyright 2005-2008 by FaktNet AS Terms Of Use Privacy Statement