0

The below exception is thrown while trying to send mail by below code:

SMPT server requires a secure connection or the client was not authenticated. The server response was 5.5.1. Authentication required

C#

string E_mail_ID = "hidden";
        try
        {
            SmtpClient gmail_client = new SmtpClient("smtp.gmail.com");
            gmail_client.Port = 587;

            gmail_client.EnableSsl = true;
            gmail_client.Timeout = 100000;
            gmail_client.DeliveryMethod = SmtpDeliveryMethod.Network;
            gmail_client.UseDefaultCredentials = false;
            gmail_client.Credentials = new NetworkCredential("hidden", "hidden");

            MailMessage msg = new MailMessage();
            msg.From = new MailAddress("hidden");
            msg.To.Add(E_mail_ID.Trim());              
            msg.Body = "Request for quotation from Jeet fly ash products, a unit of Vidya shakti niyas";
            msg.Attachments.Add(new Att![enter image description here][1]achment(pdfFile));
            gmail_client.Send(msg);
            MessageBox.Show("RFQ sent to vendor successfully");
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }
User2012384
  • 4,769
  • 16
  • 70
  • 106
Jagmeet
  • 11
  • 3

1 Answers1

0

Try the port: 465 - This is ssl for gmail.

Take a look: Configure Gmail-Account Outlook

Cadburry
  • 1,844
  • 10
  • 21
  • Same exception is coming. – Jagmeet Oct 15 '14 at 06:49
  • Hmmm.. are you using Google-Authenticator? & Is POP-Enabled for your account? – Cadburry Oct 15 '14 at 07:21
  • @Jagmeet:taka look at this thread- using System.Net.Mail instead of System.Web.Mail (because web.mail has issues with ssl) http://stackoverflow.com/questions/32260/sending-email-in-net-through-gmail – Cadburry Oct 16 '14 at 06:54