SmtpClient - Sending emails with out settings credentials.

  • Thread starter Thread starter ArunAVKumar
  • Start date Start date
A

ArunAVKumar

There is probably a issue with SmtpClient and the connection pooling.

Scenario:
1. Send a MailMessage using SmtpClient.Send method, with out setting
SmtpClient.Credentials or SmtpClient.UseDefaultCredentials.
( It is possible to send messages to internal email address with Outlook
2007 with annonymus connections)

2. Send another MailMessage using new SmtpClient.Send method,this time set
the SmtpClient.Credentials or SmtpClient.UseDefualtCredentials.
(Sending email to external account will need credentials to be set)

Step 2 will throw a SmtpFailedRecipientException (Unable to relay messages),
though Credentials was provided in the SmtpClient.

I think this is becuase of the Connection Pooling. Looks like Connection
Pool manager is smart enough to redo the connection when the credentials are
set, and they dont match in successive calls.
But it doesnt do the same, when the Credentials are null for the pooled
connection.

Any suggestion/help on this problem will be helpful
 
If you don't do step 1 at all, does step 2 work?

I know, its a simple(dumb) question, but one worth asking just to make sure.
 
Yes.
I can pass in Default Credentials and send email to external address with
out any problem, if thats the first thing I do.

The problem happens only if i had already send an internal email connection
to exchange as anonymous.
 
Back
Top