Have you looked into using 3rd party mail components like AspNetEmail:

 http://www.aspnetemail.com/

or an open source one:

 http://dotnetopenmail.sourceforge.net/

Both of those capture their interaction with the mail server:

READ> 220 smpt.example.com 
SENT> EHLO acme
READ> 250-mail.example.com
250-PIPELINING
250-SIZE 31457280
250 8BITMIME
504 Unrecognized authentication type

You could write an async smtp appender that records failed mail sends.

--- "Moss, Barney" <[EMAIL PROTECTED]> wrote:

> Hi all-
> I've noticed the SmtpAppender occasionally fails to send emails. 
> I've run it with log4net debugging enabled and got this from the
> logs:
> 
> log4net: Hierarchy: Shutdown called on Hierarchy
> [log4net-default-repository]
> log4net:ERROR [SmtpAppender] Error occurred while sending e-mail
> notification.
> System.Web.HttpException: Could not access 'CDO.Message' object. --->
> System.Reflection.TargetInvocationException: Exception has been
> thrown by the target of an invocation. --->
> System.Runtime.InteropServices.COMException (0x80040213): The
> transport failed to connect to the server.
> 
>    --- End of inner exception stack trace ---
>    at System.RuntimeType.InvokeDispMethod(String name, BindingFlags
> invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers,
> Int32 culture, String[] namedParameters)
>    at System.RuntimeType.InvokeMember(String name, BindingFlags
> invokeAttr, Binder binder, Object target, Object[] args,
> ParameterModifier[] modifiers, CultureInfo culture, String[]
> namedParameters)
>    at System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj,
> String methodName, Object[] args)
>    --- End of inner exception stack trace ---
>    at System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj,
> String methodName, Object[] args)
>    at System.Web.Mail.CdoSysHelper.Send(MailMessage message)
>    at System.Web.Mail.SmtpMail.Send(MailMessage message)
>    at log4net.Appender.SmtpAppender.SendBuffer(LoggingEvent[] events)
> 
> This is an error we've encountered whilst using the CDO system - it
> seems to be a less-than-completely-reliable component.  We resolved
> it here by retrying a few times in a loop when this error is caught.
> Would it be possible for log4net to retry sending when SmtpMail.Send
> throws an exception?  Or is there a way I can detect and retry in
> client-level code?
> 
> -thanks, Barney Moss
> 
> log4net 1.2.9
> .Net 1.1
> 
> 
> 
>
==============================================================================
> Please access the attached hyperlink for an important electronic
> communications disclaimer: 
> 
> http://www.csfb.com/legal_terms/disclaimer_external_email.shtml
> 
>
==============================================================================
> 
> 

Reply via email to