I'd like to send email from my ecommerce web by using a Gmail but I don't know how to modify the code(I didn't write it myself). Thanks for your help.
This's the code :
// Generic method for sending emails
public static void SendMail(string from, string to, string subject, string body)
{
// Configure mail client (may need additional code for authenticated SMTP servers)
SmtpClient mailClient = new SmtpClient(ABCConfiguration.MailServer);
NetworkCredential nc = new NetworkCredential("abc@gmail.com", "1234");
mailClient.Credentials = nc;
// Create the mail message
MailMessage mailMessage = new MailMessage("abc@gmail.com", to, subject, body);
// Send mail
mailClient.Send(mailMessage);
}
In web.config
<add key="MailServer" value="smtp.gmail.com " />
This's gmail configuration :
Incoming Mail (POP3) Server - requires SSL: pop.gmail.com
Use SSL: Yes
Port: 995
Outgoing Mail (SMTP) Server - requires TLS: smtp.gmail.com (use authentication)
Use Authentication: Yes
Use STARTTLS: Yes (some clients call this SSL)
Port: 465 or 587