.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

The SMTP server requires a secure connection or the client was not authenticated.

Posted By: parthiban     Posted Date: February 12, 2013    Points:5   Category :ASP.Net
protected void sendemail()
{
System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
//message.To.Add(new MailAddress("md.shadab.anwar@gmail.com"));
message.To.Add(new MailAddress(txtemail.Text.ToString()));
//string filename;
//filename = string.Concat(txtuploadfile.Text.Replace(@"\", @"\\"));
message.Subject = "New User Registration for " + txtuser.Text.ToString();
message.From = new System.Net.Mail.MailAddress("admin@XYZ.com");
//message.Body =
message.IsBodyHtml=true;




System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("smtp.gmail.com", 587);

smtp.EnableSsl = true;

smtp.Send(message);
}

Responses
Author: Amit Mehra             
Posted Date: February 21, 2013     Points: 20   

Hi,

Since you are using gmail to send mail and gmail require secure connection. so add this in your web.config file


<network host="smtp.gmail.com" enableSsl="true" />

Hope this will help you

Thanks,
Amit
Please "Mark As Answer " if this post help you.


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend