Failure sending mail. unable to connect to remote server.(In Asp.net)?
-
I am trying to send mails using gmail Smtp server from my asp.net application.But i am getting error as below. System.Net.Mail.SmtpException: Failure sending mail. ---> System.Net.WebException: Unable to connect to the remote server ---> 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 202.86.4.47:587 at System.Net.Sockets.Socket.DoConnect(EndP… endPointSnapshot, SocketAddress socketAddress) at System.Net.Sockets.Socket.InternalConnec… remoteEP) at System.Net.ServicePoint.ConnectSocketInt… connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) Here is the Code: string from = "[email protected]"; string to = "[email protected]" ; System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage(); mail.To.Add(to); mail.From = new MailAddress(from, "One Ghost" , System.Text.Encoding.UTF8); mail.Subject = "This is a test mail" ; mail.SubjectEncoding = System.Text.Encoding.UTF8; mail.Body = "This is Email Body Text"; mail.BodyEncoding = System.Text.Encoding.UTF8; mail.IsBodyHtml = true ; mail.Priority = MailPriority.High; SmtpClient client = new SmtpClient(); client.UseDefaultCredentials = false; //Add the Creddentials- use your own email id and password client.Credentials = new System.Net.NetworkCredential(from, "mygmailpassword"); client.Port = 587; // Gmail works on this port client.Host = "smtp.gmail.com"; client.EnableSsl = true; //Gmail works on Server Secured Layer try { client.Send(mail); } catch (Exception ex) { Exception ex2 = ex; string errorMessage = string.Empty; while (ex2 != null) { errorMessage += ex2.ToString(); ex2 = ex2.InnerException; } HttpContext.Current.Response.Write(error… ); } // end try
-
Answer:
Gmails SSL server is port 465. 587 is non SSL Edit: See if any of this information is helpful. http://techblissonline.com/gmail-smtp/
satish k at Yahoo! Answers Visit the source
Related Q & A:
- How can I allow user to create posts in website using ASP.NET?Best solution by Programmers
- How to Undo previous action in asp.net?Best solution by forums.asp.net
- How to Search using jQuery ASP.Net?Best solution by Stack Overflow
- How to Play Audio files in ASP.NET?Best solution by Stack Overflow
- How to save high resolution image canvas to server using asp.net?Best solution by Stack Overflow
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.