views:

150

answers:

1

Perhaps this is more of an IIS question than programming, but I'll throw it out there nonetheless.

I am attempting to send an email via SMTP with C# using the following test code:

//params: from email, to email, subject, body
MailMessage m = new MailMessage( <sendemail>, <receiveemail>, "testsubject", "Testbody" );

SmtpClient c = new SmtpClient( <SMTP Server> );

c.Send( m );

Extremely simple. I am avoiding credentials entirely because of the configuration on my SMTP server:

alt text

This should allow me to connect without credentials. Alternatively I've tried empty strings for username/password, and default credentials.

When I send attempt to send, I get the "Sending SMTP Email to failed with the following error: Mailbox unavailable. The server response was: 5.7.1 Unable to relay for " Error. I go to the relay section of IIS, and it is as follows:

alt text

So my thought is even though the "Allow all computers which successfully authenticate to relay" option is enabled, since I allow anonymous authentication my application is not able to relay. Is this the case? If so, how do I go about fixing my code to be able to relay? I've tried messages to emails inside and outside of the domain, to no avail. This is a server 2003 machine.

+1  A: 

Your assessment is correct.

You can either switch to using authenticated connections, or else add all of the IP's/Domains that your code will run from to the relay exceptions list.

John Weldon
Thank you for the input. I' will give this a try.
Kevin