when i use to send mail using gmail error occur enable to connect to remote server??
help me how to sove this error
private void button1_Click(object sender, EventArgs e)
{
try
{
MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
mail.From = new MailAddress("[email protected]");
mail.To.Add("[email protected]");
mail.Subject = "Test Mail";
mail.Body = "This is for testing SMTP mail from GMAIL";
SmtpServer.Port = 587;
SmtpServer.Credentials = new System.Net.NetworkCredential("username", "password");
SmtpServer.EnableSsl = true;
SmtpServer.Send(mail);
MessageBox.Show("mail Send");
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
Loading
junaid sarfrazPosted Feb 20, 2011, 11:35 PM
Suthish NairPosted Feb 19, 2011, 12:32 PM
Junaid,
Check with your network firewall team, might blocking the gmail port.
Janis PeksaPosted Feb 19, 2011, 7:46 AM
Did someone else works it too ?
Sam HobbsPosted Feb 19, 2011, 4:23 AM
Janis PeksaPosted Feb 19, 2011, 3:46 AM
And I have the same error like this dude.
So maybe someone have good solution for this ?
With example code ?
Sam HobbsPosted Feb 18, 2011, 5:53 PM
When I ping smtp.gmail.com the IP address is 74.125.155.109 but your error message says 74.125.115.109. I don't know why that is and if it is an indication of a problem. I think the problem is more likely that you have an incorrect parameter, such as (perhaps) the account name or password.
Sam HobbsPosted Feb 18, 2011, 5:48 PM
theLizard, did you research what you said before posting or are are you shooting from the hip? According to What Are the Gmail SMTP Settings? it is possible to send mail through Gmail. Also see Gmail's official help article Configuring other mail clients which shows how to use smtp.gmail.com as an Outgoing Mail (SMTP) Server.
theLizardPosted Feb 18, 2011, 5:18 PM
Janis PeksaPosted Feb 18, 2011, 8:59 AM
I tried out few sources noone let to connect to server.
junaid sarfrazPosted Feb 18, 2011, 12:27 AM
System.Net.Mail.SmtpException: Failure sending mail. ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: A socket operation was attempted to an unreachable host 74.125.115.109:587 at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP) at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) --- End of inner exception stack trace --- at System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& 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) at System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout) at System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port) at System.Net.Mail.SmtpTransport.GetConnection(String host, Int32 port) 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 mail.Form1.button1_Click(Object sender, EventArgs e) in C:\Documents and Settings\junaid\My Documents\Visual Studio 2008\Projects\mail\mail\Form1.cs:line 42
junaid sarfrazPosted Feb 18, 2011, 12:23 AM
Sam HobbsPosted Feb 17, 2011, 8:14 PM
Can you show the complete and accurate error message? That will help, except it might be a problem if it is not in English. Also look at the articles in this web site; I see one in the list at the right side of this window that is specifically about sending gmail.
Suthish NairPosted Feb 17, 2011, 4:03 PM
Janis PeksaPosted Feb 17, 2011, 8:01 AM
Try write this MessageBox.Show(ex.Message);
Don't you need to show the username and password for connection ?