Error while sending email [modified]
-
Hi, While sending email using the SmtpClient() object I encounter the below error message Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host A small piece of info - My development Virtual Machine is in to other VLAN & the SMTP Server belongs to different. Find below code written to send email
MailMessage mailMessage = new MailMessage(); mailMessage.From = new MailAddress("some email address..."); mailMessage.To.Add(new MailAddress("some email address...")); mailMessage.IsBodyHtml = true; mailMessage.Subject = "Test Mail"; mailMessage.Body = "Test Mail"; // Instantiate a new instance of SmtpClient SmtpClient mSmtpClient = new SmtpClient(); // Send the mail message mSmtpClient.Host = "SMTP IP Address"; mSmtpClient.Send(mailMessage);
Is this a network issue? Or do I need to provide the credentials as well?
Regards, Vipul Mehta
modified on Wednesday, November 12, 2008 10:17 AM
-
Hi, While sending email using the SmtpClient() object I encounter the below error message Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host A small piece of info - My development Virtual Machine is in to other VLAN & the SMTP Server belongs to different. Find below code written to send email
MailMessage mailMessage = new MailMessage(); mailMessage.From = new MailAddress("some email address..."); mailMessage.To.Add(new MailAddress("some email address...")); mailMessage.IsBodyHtml = true; mailMessage.Subject = "Test Mail"; mailMessage.Body = "Test Mail"; // Instantiate a new instance of SmtpClient SmtpClient mSmtpClient = new SmtpClient(); // Send the mail message mSmtpClient.Host = "SMTP IP Address"; mSmtpClient.Send(mailMessage);
Is this a network issue? Or do I need to provide the credentials as well?
Regards, Vipul Mehta
modified on Wednesday, November 12, 2008 10:17 AM
You may want to see if the SMTP server you're using demands you provide credentials to use it.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008 -
Hi, While sending email using the SmtpClient() object I encounter the below error message Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host A small piece of info - My development Virtual Machine is in to other VLAN & the SMTP Server belongs to different. Find below code written to send email
MailMessage mailMessage = new MailMessage(); mailMessage.From = new MailAddress("some email address..."); mailMessage.To.Add(new MailAddress("some email address...")); mailMessage.IsBodyHtml = true; mailMessage.Subject = "Test Mail"; mailMessage.Body = "Test Mail"; // Instantiate a new instance of SmtpClient SmtpClient mSmtpClient = new SmtpClient(); // Send the mail message mSmtpClient.Host = "SMTP IP Address"; mSmtpClient.Send(mailMessage);
Is this a network issue? Or do I need to provide the credentials as well?
Regards, Vipul Mehta
modified on Wednesday, November 12, 2008 10:17 AM
Vipul Mehta wrote:
Is this a network issue?
It may be. Is the From address in the same domain as the SMTP server? A lot of installations set the SMTP server to refuse relaying foreign addresses, that is the server will not transport any email that didn't originate in its own domain. For instance, if I send an email from user@mydomain.com using the server smtp.yourdomain.com, if relaying is disabled on the server, my email will be rejected. This is to protect SMTP servers from being used to send spam, and is usually a good practice for most organizations.
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
-
Vipul Mehta wrote:
Is this a network issue?
It may be. Is the From address in the same domain as the SMTP server? A lot of installations set the SMTP server to refuse relaying foreign addresses, that is the server will not transport any email that didn't originate in its own domain. For instance, if I send an email from user@mydomain.com using the server smtp.yourdomain.com, if relaying is disabled on the server, my email will be rejected. This is to protect SMTP servers from being used to send spam, and is usually a good practice for most organizations.
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
OK I got a chance to talk to our network team & there was some blocking done from their side & they will make appropriate settings to nake this working. Thakns very much for all your prompt replies
Regards, Vipul Mehta