Note that there are some explanatory texts on larger screens.

plurals
  1. POC# SMTP email sending code fails for Yahoo Mail but works fine for other servers, can anyone help?
    text
    copied!<p>I am using this code to send an SMTP email via the yahoo SMTP server, it is for a personal project I am writing.</p> <pre><code>using System.Net.Mail; using System.Net; SmtpClient theClient = new SmtpClient("smtp.mail.yahoo.com", 465); theClient.UseDefaultCredentials = false; theClient.Credentials = new NetworkCredential("username", "password"); theClient.EnableSsl = true; MailMessage theMessage = new MailMessage("username@yahoo.com", "to.someone@gmail.com"); theMessage.Subject = "Dave test from C# subject"; theMessage.Body = "Dave test from C# body"; theClient.Send(theMessage); </code></pre> <p>It's all pretty standard code for sending SMTP email, but... the server seems to throw an error. It forcibly terminates the connection. This does not happen if I use other SMTP servers like Gmail, Windows Live or various other ISP Smtp servers.</p> <p>This is the exception and stack trace: </p> <pre><code>System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. at System.Net.Mail.SmtpClient.Send(MailMessage message) at ConsoleApplication1.Program.Main(String[] args) in E:\dev\ARCSoftware.FTPProcessor\ConsoleApplication1\Program.cs:line 28 </code></pre> <p>I know the problem is not environmental though as I can send to the same server with these exact settings using Outlook Express. I am wondering if I need to send a certificate or something?</p> <p>If you, or anyone you know where has any ideas about this I would greatly appreciate some help.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload