sukesh
sukesh

Reputation: 2523

Mailbox unavailable. The server response was: Requested mail action not taken: mailbox unavailable

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("[email protected]", "My Name");
                    var toAddress = new MailAddress("[email protected]", "");

                    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.

Upvotes: 1

Views: 3786

Answers (2)

Prashant Datir
Prashant Datir

Reputation: 1

Need to create an App password from this url https://login.yahoo.com/account/security

Click on Manage App password: Select app type (Other if you don't know) Click to generate Copy the password and use this password as a login password while sending an email.

Upvotes: 0

python_kaa
python_kaa

Reputation: 1096

Other than using oAuth2, you can also activate access to less secure apps within your Yahoo account here: https://login.yahoo.com/account/security

SmtpClient will work normally. But you will be repititve rembembered from Yahoo to deactivate it again.

Upvotes: 1

Related Questions