Click here to Skip to main content
11,481,265 members (65,128 online)
Rate this: bad
good
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
try
{
    MailMessage Msg = new MailMessage();
    // Sender e-mail address.
    Msg.From = new MailAddress(txtemail.Text);
    // Recipient e-mail address.
    Msg.To.Add("manojmuraliconnect@gmail.com");
    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.gmail.com";
    smtp.Port = 587;
    smtp.Credentials = new System.Net.NetworkCredential("manojmuraliconnect@gmail.com", "Password");
    smtp.EnableSsl = true;
    smtp.Send(Msg);
    ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "ASET", "<script type='text/javascript'>alert('Your Message Has Been Send ');</script>", false);
    CleaContents();
}
catch (Exception ex)
{
    lbltext.Text = ex.Message;
}
Posted 28-Aug-13 19:46pm
Edited 28-Aug-13 20:06pm
v3
Comments
Prasad Khandekar at 29-Aug-13 1:10am
   
Hello Manoj,

Please have a look at this thread. (http://stackoverflow.com/questions/704636/sending-email-through-gmail-smtp-server-with-c-sharp)

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

Solution 1

Look at:
Msg.From = new MailAddress(txtemail.Text);
...
smtp.Credentials = new System.Net.NetworkCredential("manojmuraliconnect@gmail.com",
If txtemail.Text is different from "manojmuraliconnect@gmail.com", 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).
  Permalink  
Comments
ProgramFOX at 29-Aug-13 2:41am
   
+5!
Rate this: bad
good
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.
  Permalink  
Comments
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...
Vikas Kumar at 28-Sep-14 16:34pm
   
Thanks! I got my solution using Account password change
Vishwajeet Awasthi at 19-Feb-15 6:27am
   
It was really helpful, Thanks ..
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

there is a very simple solutin for this

instead of using manojmuraliconnect@gmail.com 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
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

Msg.From = new MailAddress(txtemail.Text);

smtp.Credentials = new System.Net.NetworkCredential("txtemail", "Password");
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 6

I had the same problem. After turning off the two steps verification, it worked like a charm.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 7

  Permalink  
Comments
Tomas Takac at 11-Jan-15 6:15am
   
Please note that the question is from August 2013 i.e. it's 1.5 years old! Do not answer old question like this. First it doesn't make sense and secondly you expose yourself to the risk of being downvoted.

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 294
1 OriginalGriff 220
2 CPallini 135
3 CHill60 130
4 Richard MacCutchan 80
0 Sergey Alexandrovich Kryukov 8,184
1 OriginalGriff 7,701
2 Sascha Lefèvre 3,114
3 Maciej Los 2,491
4 Richard Deeming 2,335


Advertise | Privacy | Mobile
Web02 | 2.8.150520.1 | Last Updated 10 Jan 2015
Copyright © CodeProject, 1999-2015
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