I'm unable to send an email using the yahoo client. The same code & port works fine with gmail credentials.
Testing this in my local system.
var fromAddress = new MailAddress("myname@yahoo.com", "My Name");
var toAddress = new MailAddress("validemail@yahoo.com", "");
var smtp = new SmtpClient
{
Host = "smtp.mail.yahoo.com",
Port = 587,
EnableSsl = false,
DeliveryMethod = SmtpDeliveryMethod.Network,
UseDefaultCredentials = false,
Credentials = new NetworkCredential(fromAddress.Address, "P@s5word")
};
using (var message = new MailMessage(fromAddress, toAddress)
{
Subject = emailSubject,
Body = emailBody,
IsBodyHtml = true
})
{
//turning the security off for testing
ServicePointManager.ServerCertificateValidationCallback = delegate (object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{ return true; };
smtp.Send(message);
}
Also tried by enabling the SSL, with no luck.
UPDATE:
I realize that oAuth2 needs to be used in this case. I have created an app in Yahoo for my project and have the client ID and client secret.
I'm unable to find any info on how to use these details to send an email using Yahoo.