Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: ASP.NET
when working in the application it is working fine and receiving mail. when it is hosted message sending failed and i am getting the error like "The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at" please help me

my code is
    MailMessage Msg = new MailMessage();
    // Sender e-mail address.
    Msg.From = new MailAddress(txtemail.Text);
    // Recipient e-mail address.
    Msg.Subject = "Enquiry";
    Msg.Body = "Sender : " + txtemail.Text + "\n" + "Name : " + txtname.Text + "\n" + "Phone : " + txtphone.Text + "\n" + "Address:" + txtaddress.Text + "\n" + "Enquiry:" + txtenquiry.Text;
    // your remote SMTP server IP.
    SmtpClient smtp = new SmtpClient();
    smtp.Host = "";
    smtp.Port = 587;
    smtp.Credentials = new System.Net.NetworkCredential("", "Password");
    smtp.EnableSsl = true;
    ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "ASET", "<script type='text/javascript'>alert('Your Message Has Been Send ');</script>", false);
catch (Exception ex)
    lbltext.Text = ex.Message;
Posted 28-Aug-13 18:46pm
Edited 28-Aug-13 19:06pm
Prasad Khandekar at 29-Aug-13 1:10am
Hello Manoj,
Please have a look at this thread. (
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Look at:
Msg.From = new MailAddress(txtemail.Text);
smtp.Credentials = new System.Net.NetworkCredential("",
If txtemail.Text is different from "", Google will not accept that message: you must not send an email on behalf of someone else (many mail servers are configured in this way: no provider likes spammers).
ProgramFOX at 29-Aug-13 2:41am
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Very Strong Password is needed,
I changed my Account's Password to somthing like: %TGB6yhn^YHN5tgb and it works perfect.
Member 10492994 at 20-Jan-14 3:57am
I tested this method, but I can't get any result.
Venkata Sailendra Kumar at 30-Jun-14 5:03am
Thanks mate!!! I tried a lot with different options but changing the password strongly works perfectly for me...
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

there is a very simple solutin for this
instead of using gmail addresss
use email address that is created on the server on which you are hosting your application
this problem causes because gmail server prevents to send email through gmail server

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

  Print Answers RSS
0 OriginalGriff 448
1 Sergey Alexandrovich Kryukov 290
2 PhilLenoir 95
3 Uma Shankar Patel 80
4 CB Sharma 79
0 Sergey Alexandrovich Kryukov 6,532
1 OriginalGriff 5,976
2 CPallini 2,473
3 Richard MacCutchan 1,687
4 Abhinav S 1,550

Advertise | Privacy | Mobile
Web03 | 2.8.140821.2 | Last Updated 18 Jan 2014
Copyright © CodeProject, 1999-2014
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