Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
Hello i am facing one problem,,,
 
Send Email though Asp.Net using Gmail Smtp Server but error shows
"The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required."
 
Coding is as follows.
protected void Button1_Click(object sender, EventArgs e)
    {
        string from ="meemail@gmail.com";
        string to= "youemail@gmail.com";
 
        System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
        mail.To.Add(to);
        mail.From=new MailAddress(from,"One Ghost",System.Text.Encoding.UTF8);
        mail.Subject="This is a test mail";
        mail.SubjectEncoding=System.Text.Encoding.UTF8;
        mail.Body="This is Email Body Text";
        mail.BodyEncoding=System.Text.Encoding.UTF8;
        mail.IsBodyHtml=true;
        mail.Priority=MailPriority.High;
        
        SmtpClient client=new SmtpClient();
 
        client.Credentials=new System.Net.NetworkCredential(from,"Password");
        
        client.Port=587;
        client.Host="smtp.gmail.com";
        client.EnableSsl=true;
        try
            {
                
                client.Send(mail);
            }
            catch(Exception ex)
                {
                    Exception ex2=ex;
                    string errorMessage=string.Empty;
                    while(ex2!=null)
                    {
                        errorMessage +=ex2.ToString();
                        ex2=ex2.InnerException;                   
                    }
                    HttpContext.Current.Response.Write(errorMessage);
                }               
    }
}
Posted 1-Apr-13 2:36am
v2
Comments
Inderveer kaur at 3-Apr-13 9:15am
   
Hello Tadit Dash Sir,
I have send email to another person through asp.net using above code.But now I want to send email to multiple person. Like
from=meemail@gmail.com
to=you1@gmail.com,you2@gmail.com
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Have look on following thread:
Enabling SSL[^]
From similar discussion[^]
  Permalink  
Comments
Sheikh Muhammad Haris at 1-Apr-13 15:09pm
   
good thinking .. +5
Inderveer kaur at 2-Apr-13 1:04am
   
It has not solved my issue...........same error is still there.....
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

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.To.Add(TextBox4.Text);
            msg.Subject = "Welcome To Website";
           
            msg.Body = "You Have Successfully Registered" ;
            msg.From = new MailAddress("welcome@gmail.com"); // Your Email Id
            SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
            SmtpClient client1 = new SmtpClient("smtp.mail.yahoo.com", 465);
            client.Credentials = cred;
            client.EnableSsl = true;
            client.Send(msg);
}
}
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

u can use the
client.Port=25;
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 8,149
1 Sergey Alexandrovich Kryukov 7,287
2 DamithSL 5,614
3 Manas Bhardwaj 4,986
4 Maciej Los 4,910


Advertise | Privacy | Mobile
Web04 | 2.8.1411023.1 | Last Updated 19 Feb 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