I am using following code to send email. The Code works correctly in my local Machine. But on Production server i am getting the error message
var fromAddress = new MailAddress("mymailid@gmail.com");
var fromPassword = "xxxxxx";
var toAddress = new MailAddress("yourmailid@yourdoamain.com");
string subject = "subject";
string body = "body";
System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient
{
Host = "smtp.gmail.com",
Port = 587,
EnableSsl = true,
DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network,
UseDefaultCredentials = false,
Credentials = new NetworkCredential(fromAddress.Address, fromPassword)
};
using (var message = new MailMessage(fromAddress, toAddress)
{
Subject = subject,
Body = body
})
smtp.Send(message);
And on my Gmail A/c I have received the following email after i ran the code from production server
Hi ,
Someone recently used your password to try to sign in to your Google
Account mymailid@gmail.com. This person was using an application such
as an email, client or mobile device.We prevented the sign-in attempt in case this was a hijacker trying to
access your account. Please review the details of the sign-in attempt:Friday, 3 January 2014 13:56:08 o’clock UTC IP Address: xxx.xx.xx.xxx
(abcd.net.) Location: Philadelphia PA, Philadelphia, PA, USAIf you do not recognise this sign-in attempt, someone else might be
trying to access your account. You should sign in to your account and
reset your password immediately.Reset password
If this was you and you are having trouble accessing your account,
complete the troubleshooting steps listed at
http://support.google.com/mail?p=client_loginYours sincerely, The Google Accounts team