Joshua H
Joshua H

Reputation: 75

SmtpClient "Request failed; Mailbox unavailable"

Im trying to send and Email with SmtpClient at the yahoo smtp server

"smtp.mail.yahoo.com", 587

The first time trying, I got an email telling me to change my account settings to allow smtp requests to work, but after doing that, the mailbox is unavailable.

SendMail method:

public void SendMail(string name, string from, string to, string subject, string content)
    {
        try
        {
            using (var mail = new MailMessage())
            {
                const string email = @"[email protected]";
                const string pw = "***";

                var login = new NetworkCredential(email, pw);

                mail.From = new MailAddress(from);
                mail.To.Add(new MailAddress(to));
                mail.Subject = subject;
                mail.Body = content;
                mail.IsBodyHtml = true;

                try
                {
                    using (var client = new SmtpClient("smtp.mail.yahoo.com", 587))
                    {
                        client.EnableSsl = true;
                        client.DeliveryMethod = SmtpDeliveryMethod.Network;
                        client.UseDefaultCredentials = false;
                        client.Credentials = login;
                        client.Send(mail);
                    }
                }
                finally
                {
                    mail.Dispose();
                }
            }
        }
        catch(Exception ex)
        {

        }
    }

Action:

[HttpPost]
    public ActionResult ContactSend(Mail mail)
    {
        if(ModelState.IsValid)
        {
            var toAdress = @"[email protected]";
            var fromAdress = mail.Email;
            var subject = mail.Betreff;
            var name = mail.Name;
            var content = new StringBuilder();
            content.Append("Name: " + name + "\n");
            content.Append("Email: " + fromAdress + "\n\n");
            content.Append(mail.Content);

            SendMail(name, fromAdress, toAdress, subject, content.ToString());

        }

        return RedirectToAction("Kontakt", "Home");
    }

Checked all the login information and since i got an email from yahoo the first time i tried it they seem to work.

Exception:

Upvotes: 3

Views: 4751

Answers (1)

Terry Carmen
Terry Carmen

Reputation: 3896

"Mailbox Unavailable" is a message from Yahoo's mail server, but means very little except that they didn't want to talk to you.

The "To:" address might be out of space or spelled wrong, or they might not like your IP address or any of a hundred other things.

You can google for yahoo postmaster help and see if they have any suggestions.

You have successfully connected but they refused to accept your mail. You would need actual information to know why.

Upvotes: 3

Related Questions