Having trouble sending an email with FluentEmail using a Gmail server. When I run my code I get a System.AggregateException with a server response 5.7.0 Authentication Required.
I have tried turning allow less secure apps to ON in my Gmail settings but it still doesn't work. Have I not properly formatted the code or is this a google server issue?
namespace EmailDemo
{
class Program
{
static async Task Main(string[] args)
{
SmtpClient smtp = new SmtpClient
{
Host = "smtp.gmail.com",
Port = 587,
EnableSsl = true,
UseDefaultCredentials = false,
DeliveryMethod = SmtpDeliveryMethod.Network,
Credentials = new NetworkCredential("AGmailAccount@gmail.com", "AGmailPW")
};
Email.DefaultSender = new SmtpSender(smtp);
var email = Email
.From("GmailUser@gmail.com")
.To("GmailReceiver@gmail.com")
.Subject("Test Email")
.Body("email content yes we love content YARRRR");
var test = email.Send();
}
}