I can get both System.Net.Mail and System.Web.Mail to work with GMail, but I can’t get them both to work with smtp.att.yahoo.com.
I get the SMTP settings from my own Web.config keys. These settings work when I send using System.Web.Mail, but fail with System.Net.Mail.
<add key='SmtpServer' value='smtp.att.yahoo.com'/> <add key='SmtpServerAuthenticateUser' value='ctrager@sbcglobal.net'/> <add key='SmtpServerPort' value='465'/> <add key='SmtpUseSSL' value='1'/> <add key='SmtpServerAuthenticatePassword' value='MY PASSWORD'/>
Here is the code that grabs my settings, and works with GMail, fails with att.yahoo:
SmtpClient smtp; if (!string.IsNullOrEmpty(Util.get_setting('SmtpServer', ''))) { smtp = new SmtpClient(Util.get_setting('SmtpServer', '')); } else { smtp = new SmtpClient(); } if (!string.IsNullOrEmpty(Util.get_setting('SmtpServerAuthenticatePassword', ''))) smtp.Credentials = new System.Net.NetworkCredential( Util.get_setting('SmtpServerAuthenticateUser', ''), Util.get_setting('SmtpServerAuthenticatePassword', '')); if (!string.IsNullOrEmpty(Util.get_setting('SmtpServerPort', ''))) smtp.Port = int.Parse(Util.get_setting('SmtpServerPort', '')); if (Util.get_setting('SmtpUseSSL', '0') == '1') smtp.EnableSsl = true; smtp.Send(message);
Is this my problem?
I’ve learned the answer. The answer is:
Because System.Net.Mail does not support ‘implicit’ SSL, only ‘explicit’ SSL.