Click here to Skip to main content
13,140,591 members (53,068 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I am getting following error while sending a mail from my website. In local iis it is working but in production server it is getting following error.

Sys.WebForms.PageRequestManagerServerErrorException: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required.

The code i have written is
public void SendMail(string ToEmailAddress, string Body, string Subject)
            SmtpClient smtpClient = new SmtpClient();
            smtpClient.Host = System.Configuration.ConfigurationManager.AppSettings["SmtpClientHost"].ToString();
            smtpClient.Port = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["SmtpClientport"].ToString());
            smtpClient.Credentials = new System.Net.NetworkCredential(System.Configuration.ConfigurationManager.AppSettings["FromEmail"].ToString(), System.Configuration.ConfigurationManager.AppSettings["MailPassword"].ToString());
            smtpClient.EnableSsl = true;
            MailMessage messege = new MailMessage();
            MailAddress mailAddress = new MailAddress(System.Configuration.ConfigurationManager.AppSettings["FromEmail"].ToString(), System.Configuration.ConfigurationManager.AppSettings["Name"].ToString());
            messege.From = mailAddress;
            messege.Subject = Subject;
            messege.Body = Body;
            messege.IsBodyHtml = true;

In web.config i have mention settings like

       <add key="SmtpClientHost" value=""/>
       <add key="SmtpClientport" value="587"/>
       <add key="FromEmail" value=""/>
       <add key="MailPassword" value="myPassword"/>
       <add key="Name" value="CRACKERSADMIN"/>

Please help me
Posted 3-Sep-12 18:58pm
Updated 3-Sep-12 19:14pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Try configuration like following, make sure you have configured SMTP configuration in Web.Config:
     <smtp from="">
       <network host="somesmtpserver" port="25" userName="name" password="pass" defaultCredentials="true" />

If needed, have a look at this Microsoft Video tutorial: Use ASP.NET to send Email from Website[^]

Have a look at this tip too: Sending an Email in C# with or without attachments: generic routine.[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.170915.1 | Last Updated 4 Sep 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100