EDN Admin
Well-known member
When Im at the office, and directly connected to the company network, the following works to send email:
MailMessage message = new MailMessage();
SmtpClient smtp = new SmtpClient("hostname");
message.Subject = "Email test.";
message.From = new MailAddress("user@company.com");
message.To.Add("user@company.com");
message.Body = "Hey, it went through!";
smtp.Send(message);
But when Im working from home and try this, it times out. I have tried setting credentials, port, SSL etc., as shown below (and variations thereof), but this does not help.
smtp.Credentials = new System.Net.NetworkCredential("user", "password");
smtp.UseDefaultCredentials = false;
smtp.EnableSsl = true;
smtp.Port = 465;
Thunderbird works fine for me to send and receive email through the same hostname. The Thunderbird outgoing SMTP settings show port 465 and SSL enabled. I have tried port 587 as some posts have suggested. I have put an exception in windows firewall for port 465. If I try port 110 - which Thunderbird uses for the incoming mail - I get a different exception:
Syntax error, command unrecognized. The server response was:
<369.1366915548@hostname>
which seems to indicate that Im getting through to the server somewhat. Any ideas on what Im missing to get this to work to send email when Im outside the company network?
RSBeech
View the full article
MailMessage message = new MailMessage();
SmtpClient smtp = new SmtpClient("hostname");
message.Subject = "Email test.";
message.From = new MailAddress("user@company.com");
message.To.Add("user@company.com");
message.Body = "Hey, it went through!";
smtp.Send(message);
But when Im working from home and try this, it times out. I have tried setting credentials, port, SSL etc., as shown below (and variations thereof), but this does not help.
smtp.Credentials = new System.Net.NetworkCredential("user", "password");
smtp.UseDefaultCredentials = false;
smtp.EnableSsl = true;
smtp.Port = 465;
Thunderbird works fine for me to send and receive email through the same hostname. The Thunderbird outgoing SMTP settings show port 465 and SSL enabled. I have tried port 587 as some posts have suggested. I have put an exception in windows firewall for port 465. If I try port 110 - which Thunderbird uses for the incoming mail - I get a different exception:
Syntax error, command unrecognized. The server response was:
<369.1366915548@hostname>
which seems to indicate that Im getting through to the server somewhat. Any ideas on what Im missing to get this to work to send email when Im outside the company network?
RSBeech
View the full article