Click here to Skip to main content
15,888,084 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
here i try to send e-mail from my website and find code from google i use it ,when i use it with my gmail account it works fine but when i use it with my webmail account it can't send .....pls help
C#
var fromAddress = "dhiraj@xyz.in";
// any address where the email will be sending
var toAddress = "xyz@yahoo.com";

const string fromPassword = "1234";
// Passing the values and make a email formate to display
string subject = "test";
string body = "From: " + "dhirajmane" + "\n";
body += "Email: " + "dhiraj@xyz.in" + "\n";
body += "Subject: " + "hi dhiraj send this mail" + "\n";
body += "Question: \n" + "was up" + "\n";
// smtp settings
var smtp = new System.Net.Mail.SmtpClient();
{
    smtp.Host = "103.21.58.111";
    smtp.Port = 587;
    smtp.EnableSsl = true;
    smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
    smtp.Credentials = new NetworkCredential(fromAddress, fromPassword);
    smtp.Timeout = 20000;
}
// Passing values to smtp object
smtp.Send(fromAddress, toAddress, subject, body);

Response.Write("E-mail sent!");

it shoe the error
Could not send the e-mail - error: Server does not support secure connections.
Posted

So if the error message is that the server does not support secure connections, it means that you are going to have to disable SSL (Secure Sockets Layer).

Change this line:
smtp.EnableSsl = true;

to this:
smtp.EnableSsl = false;


Hope this helps! :-)
 
Share this answer
 
Comments
dhiraj mane 12-Jun-14 7:49am    
yes, it work ...thanks
i do
smtp.EnableSsl = false;
 
Share this answer
 
CSS
Please check the following link:

<a href="http://www.storm-consultancy.com/blog/development/code-snippets/sending-email-with-gmail-smtp-server-in-asp-net/">http://www.storm-consultancy.com/blog/development/code-snippets/sending-email-with-gmail-smtp-server-in-asp-net/</a>

<a href="http://stackoverflow.com/questions/454277/how-to-enable-ssl-for-smtpclient-in-web-config">http://stackoverflow.com/questions/454277/how-to-enable-ssl-for-smtpclient-in-web-config</a>
 
Share this answer
 
v2
Comments
dhiraj mane 26-Jun-14 7:35am    
thank's but i sloved it...

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