I have an ASP.NET program that sends a confirmation email with the following code:
String msgTxt = 'My Message'; try { MailMessage message = new MailMessage(); message.From = new MailAddress('info@eatrightamerica.com'); message.To.Add(new MailAddress(emailParam)); message.Bcc.Add(new MailAddress('NPClients@eatrightamerica.com')); message.Subject = 'Your Nutrition Prescription'; message.Body = msgTxt; SmtpClient client = new SmtpClient(); client.Send(message); } catch (Exception ex) { }
The web.config file has this:
<system.net> <mailSettings> <smtp> <network host='localhost' port='25' /> </smtp> </mailSettings> </system.net>
And my IIS is set to run on Port 25 (I can telnet in and test it, and it sends just fine by telnet).
Can someone direct me somewhere else to look for the problem?
Is the server you’re running your code on set up as an SMTP relay in your email environment? This can be an issue in corporate / enterprise settings in particular.