Link to home
Start Free TrialLog in
Avatar of MrShawe
MrShawe

asked on

ASP.NET, sending email by port 587 and 465 issues

I am trying to change the port I am using to send emails from my website, website is coded in ASP.NET.

I have the following code:
SmtpClient smtp = new SmtpClient("mail.ttt.com");
smtp.Port = Convert.ToInt32("25");
smtp.UseDefaultCredentials = false;
smtp.EnableSsl = false;
NetworkCredential Credentials = new NetworkCredential("ttt@ttt.com", "tttttt");
smtp.Credentials = Credentials;
smtp.Send(m);

This code works, but I encounter the following issues:...
Port 465, SSL true - no email received
Port 587, SSL true - no email received
Port 465, SSL false - no email received
Port 587, SSL false - no email received
Port 25, SSL true - EMAIL received
Port 25, SSL true- EMAIL received

When using outlook 2016 I have to use the STARTTLS setting to get the emails to receive, how does this look in when coding the website, I have google this and there doesn't seem to be a clear answer?

The reason I wish to change is that the 25 port takes forever to send the form and the 587 and 465 seem almost instant!

Thanks in advance
Avatar of Deepak Vasudevan
Deepak Vasudevan
Flag of India image

Did you see any security alert in the sending email inbox?

Another out of topic but performance related tip regarding this statement
smtp.Port = Convert.ToInt32("25");

Is that redundant string <-> int conversions required?
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.