Click here to Skip to main content
15,942,710 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
facing error while sending email from live server.

Date : 5/29/2019 12:27:16 PM

Message : Failure sending mail.
StackTrace : at System.Net.Mail.SmtpClient.Send(MailMessage message)
at AliAndAssociates.ApplicationForms.CrossNoticeManagement.CrossNoticeForm.Message()
at AliAndAssociates.ApplicationForms.CrossNoticeManagement.CrossNoticeForm.UCMemoButtonToolBar_SaveEvent(Object sender, EventArgs e)
Message : Unable to connect to the remote server
StackTrace : at System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6)
at System.Net.PooledStream.Activate(Object owningObject, Boolean async, GeneralAsyncDelegate asyncCallback)
at System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout)
at System.Net.Mail.SmtpConnection.GetConnection(ServicePoint servicePoint)
at System.Net.Mail.SmtpClient.GetConnection()
at System.Net.Mail.SmtpClient.Send(MailMessage message)
Message : 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
StackTrace : at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)

What I have tried:

SmtpClient smtp = new SmtpClient();
smtp.Host = "";
smtp.Port = 587;
smtp.UseDefaultCredentials = false;
smtp.EnableSsl = true;
smtp.Credentials = new NetworkCredential("", "abc");
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
Updated 28-May-19 21:38pm

1 solution

You should use your own SMTP server. Google mail does not generally allow you to use its server in this way.

See Richard Deeming's comments below.
Share this answer
Richard Deeming 29-May-19 10:37am    
Er, yes it does:
Send email from a printer, scanner, or app - G Suite Admin Help[^]
"Gmail SMTP server — Send mail to anyone inside or outside of your domain. This option requires you to authenticate with your Gmail or G Suite account and password."
Richard MacCutchan 29-May-19 11:36am    
I have seen a number of similar issues, and answers from other respected CPians suggest that Google does not always allow this. But, I am happy to stand corrected.
Richard Deeming 29-May-19 11:37am    
I think they occasionally make you jump through burning hoops for added security. But this one looks more like a DNS issue to me.
Richard MacCutchan 29-May-19 11:50am    
What I get when I telnet to that IP and port address:
220 ESMTP q13sm5579886iob.55 - gsmtp
EHLO foobar at your service, []
250-SIZE 35882577
221 2.0.0 closing connection q13sm5579886iob.55 - gsmtp

So DNS seems to be resolving to a valid server IP.
Richard Deeming 29-May-19 11:53am    
Perhaps it's a firewall issue. Or maybe the source IP has been blacklisted. The error certainly looks like a network issue, rather than a code issue.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900