Click here to Skip to main content
15,115,960 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
protected void SendMail()
{
var fromAddress = " training@mpldamanhour.gov.eg";
var toAddress = TextBox2.Text.ToString();
const string fromPassword = "M_123456";
string subject = TextBox3.Text.ToString();
string body = "From: " + TextBox1.Text + "\n";
body += "Email: " + TextBox2.Text + "\n";
body += "Subject: " + TextBox3.Text + "\n";

var smtp = new System.Net.Mail.SmtpClient();
{
smtp.Host = "mpldamanhour.gov.eg";
smtp.Port = 25;
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);
}


What I have tried:

try to send mail from website to emails using stmp in asp.net>show error
Server does not support secure connections.
Posted
Updated 15-Jul-18 1:05am

Look at the error message:
Server does not support secure connections.
And you specifically tell it you want a secure connection:
smtp.EnableSsl = true;
Switch that to false and try again.
   
i did
smtp.EnableSsl = true;

and show error

Service not available, closing transmission channel. The server response was: Cannot connect to SMTP server 213.158.166.78 (213.158.166.78:25), connect error 10061
   
Comments
Richard Deeming 17-Jul-18 13:07pm
   
If you want to reply to a solution, click the "Have a Question or Comment?" button under that solution.

DO NOT post your reply as a new "solution".

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