facing error while sending email from live server.
Date : 5/29/2019 12:27:16 PM
System.Net.Mail.SmtpException
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)
System.Net.WebException
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)
System.Net.Sockets.SocketException
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 108.177.111.108:587
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.gmail.com";
smtp.Port = 587;
smtp.UseDefaultCredentials = false;
smtp.EnableSsl = true;
smtp.Credentials = new NetworkCredential("abc@gmail.com", "abc");
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;