Hello,
I have an asp.net core web app, It is working on the IIS 8 windows server 2012. I need to send an e-mail to one of the action controllers. I installed the SMTP server. Did some googling and made configuration. I tried to send from one of my Gmail accounts. But I got "Delivery to the following recipients failed." error. Anyone who accomplished sending e-mail can help me, please?
Here is the sending e-mail in the controller:
public void sendMail(string body, string email) { SmtpClient client = new SmtpClient(server IP here); client.UseDefaultCredentials = false; client.Credentials = new NetworkCredential("myaccount@gmail.com", "my password"); MailMessage mailMessage = new MailMessage(); mailMessage.From = new MailAddress("myaccount@gmail.com"); mailMessage.To.Add(email); mailMessage.Body = body; mailMessage.Subject = "Serials"; client.Send(mailMessage); }
Best Regards.