Auriion
March 12th, 2009, 03:28 PM
Here's the code I'm working with:
--
String from = "sender";
String to = "recipient";
String smtp = "smtp.xxx.com";
String userName = "xxx@xxx.com";
String password = "xxxx";
String subject = "This is a test subject";
String bodyText = "This is a test email";
MailMessage message = new MailMessage(from, to, subject, bodyText);
//Sets the host and port in the arguments respectively
SmtpClient emailClient = new SmtpClient(smtp, 587);
NetworkCredential SMTPUserInfo = new NetworkCredential(userName, password);
emailClient.UseDefaultCredentials = false;
emailClient.Credentials = SMTPUserInfo;
emailClient.EnableSsl = true;
emailClient.Send(message);
--
I've tried a great number of different combinations of configurations and nothing has worked. I even checked to make sure none of my ports were being blocked by possible firewalls.
The only time the email works is when I use port 25, however my smtp host states that I can also use port 587 for sure.
Is there something I am missing?
I've also tried using gmail as an smtp server with no luck. If someone could post the code they used to successfully deliver email through smtp.gmail.com (without username and password of course) that would be very helpful.
Thanks for the feedback ahead of time.
--
String from = "sender";
String to = "recipient";
String smtp = "smtp.xxx.com";
String userName = "xxx@xxx.com";
String password = "xxxx";
String subject = "This is a test subject";
String bodyText = "This is a test email";
MailMessage message = new MailMessage(from, to, subject, bodyText);
//Sets the host and port in the arguments respectively
SmtpClient emailClient = new SmtpClient(smtp, 587);
NetworkCredential SMTPUserInfo = new NetworkCredential(userName, password);
emailClient.UseDefaultCredentials = false;
emailClient.Credentials = SMTPUserInfo;
emailClient.EnableSsl = true;
emailClient.Send(message);
--
I've tried a great number of different combinations of configurations and nothing has worked. I even checked to make sure none of my ports were being blocked by possible firewalls.
The only time the email works is when I use port 25, however my smtp host states that I can also use port 587 for sure.
Is there something I am missing?
I've also tried using gmail as an smtp server with no luck. If someone could post the code they used to successfully deliver email through smtp.gmail.com (without username and password of course) that would be very helpful.
Thanks for the feedback ahead of time.