Note that there are some explanatory texts on larger screens.

plurals
  1. PO.NET Why can't I send email?
    text
    copied!<p>Here is my code:</p> <pre><code>try { MailMessage m = new MailMessage ("testesmtpmic@gmail.com", "toMyEmail@gmail.com", "Quarterly data report.", "Hello, world."); SmtpClient client = new SmtpClient("smtp.gmail.com", 465); client.Credentials = new NetworkCredential("testesmtpmic@gmail.com", "password"); client.EnableSsl = true; client.Send(m); Console.WriteLine("sent"); } catch (InvalidOperationException ey) { Console.WriteLine(ey.Message); } catch (SmtpFailedRecipientException sm) { Console.WriteLine(sm.Message); } catch (SmtpException ex) { Console.WriteLine(ex.Message); } </code></pre> <p>This code produce this error at SmtpException: "Failure sending mail." The full is exception is this:</p> <pre><code>ex.ToString() "System.Net.Mail.SmtpException: Failure sending mail. ---&gt; System.Net.WebException: Unable to connect to the remote server ---&gt; System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 74.125.67.109:587 at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket&amp; socket, IPAddress&amp; address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception&amp; exception) --- End of inner exception stack trace --- at System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress&amp; address, Socket&amp; abortSocket, Socket&amp; abortSocket6, Int32 timeout) at System.Net.PooledStream.Activate(Object owningObject, Boolean async, Int32 timeout, GeneralAsyncDelegate asyncCallback) at System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate asyncCallback)\r\n at System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout) at System.Net.Mail.SmtpConnection.GetConnection(ServicePoint servicePoint) at System.Net.Mail.SmtpTransport.GetConnection(ServicePoint servicePoint) at System.Net.Mail.SmtpClient.GetConnection() at System.Net.Mail.SmtpClient.Send(MailMessage message) --- End of inner exception stack trace --- at System.Net.Mail.SmtpClient.Send(MailMessage message) at ConsoleApplication3.Program.Main(String[] args) in c:\\users\\alan\\documents\\visual studio 2010\\Projects\\ConsoleApplication3\\ConsoleApplication3\\Program.cs:line 24" string </code></pre>
 

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