I’m using the following basic code:
System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
msg.to.add("someone@hotmail.com");
msg.to.add("someone@gmail.com");
msg.to.add("someone@myDomain.com");
msg.From = new MailAddress("me@myDomain.com", "myDomain", System.Text.Encoding.UTF8);
msg.Subject = "subject";
msg.SubjectEncoding = System.Text.Encoding.UTF8;
msg.Body = "body";
msg.BodyEncoding = System.Text.Encoding.UTF8;
msg.IsBodyHtml = false;
//Add the Creddentials
SmtpClient client = new SmtpClient();
client.Host = "192.168.0.24";
client.Credentials = new System.Net.NetworkCredential("me@myDomain.com", "password");
client.Port = 25;
try
{
client.Send(msg);
}
catch (System.Net.Mail.SmtpException ex)
{
sw.WriteLine(string.Format("ERROR MAIL: {0}. Inner exception: {1}", ex.Message, ex.InnerException.Message));
}
Problem is the mail is only sent to the address in my domain (someone@mydomain.com) and I get the following exception for the 2 other addresses:
System.Net.Mail.SmtpFailedRecipientException: Mailbox unavailable. The server response was: No such domain at this location
I suspect it’s something to do with something blocking my smtp client but not sure how to approach this.
Any idea? thanks!
Ron is correct,just use the 587 port and it will work as u wish.
Check this code and see if it works: