Click here to Skip to main content
13,258,269 members (38,991 online)
Rate this:
Please Sign up or sign in to vote.
See more:
My site has some functionality to send email to user some perspective. I have done this. My method can sending email successfully when i am running this application from Visual Studio or My local IIS 7 server (I Configured My PC). But the remote online web server can't send email. Please give me some tips how can i solve this issue. I have already gave lot of time to google but not found this solution. My code

const string fromAddress = "";
const string fromPassword = "password";
string toAddress = account.Email;
string subject = "subject";
string body = "mail Body";
var smtp = new System.Net.Mail.SmtpClient();
smtp.Host = "";
smtp.Port = 587;
smtp.EnableSsl = true;
smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
smtp.Credentials = new NetworkCredential(fromAddress, fromPassword);
smtp.Timeout = 20000;
smtp.Send(fromAddress, toAddress, subject, body);

give me some instruction how can i solve this problem.
Posted 27-Mar-13 21:15pm
Bernhard Hiller 28-Mar-13 4:11am
what's the error message?
Member 9399759 28-Mar-13 4:32am
Thanks for reply , The exception is bellow....

The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

using System.Net;
using System.Net.Mail;

public partial class RegistrationForm : System.Web.UI.Page
       protected void Page_Load(object sender, EventArgs e)

protected void send mail(object sender, EventArgs e)

NetworkCredential cred = new NetworkCredential(email Id, Password);
            MailMessage msg = new MailMessage();
            msg.Subject = "Welcome To Website";
            msg.Body = "You Have Successfully Registered" ;
            msg.From = new MailAddress(""); // Your Email Id
            SmtpClient client = new SmtpClient("", 587);
            SmtpClient client1 = new SmtpClient("", 465);
            client.Credentials = cred;
            client.EnableSsl = true;



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 |
Web03 | 2.8.171114.1 | Last Updated 28 Mar 2013
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