Reputation: 73
I've researched extensively and have found no working solutions for my currently problem. I'm wanting to send an email through my windows live email using their SMTP server. I get the error:
"Mailbox unavailable. The server response was: 5.7.3 Requested action aborted; user not authenticated"
I've tried working with my firewall, trying to enable the SMTP settings in my account, and a couple other solutions I've found on this site and others but nothing works. In my outlook/windows account's recent activity I do not see an SMTP access, only my current sign in, even though it says I'm connecting.
I'm not opposed to using another SMTP server I'm working with C#/ASP.NET This is my code:
public static void Email(string name, string recipient, string address, string email, string info)
{
MailMessage mailMsg = new MailMessage();
mailMsg.To.Add(new MailAddress(email));
// From
MailAddress mailAddress = new MailAddress("[email protected]");
mailMsg.From = mailAddress;
//Content
mailMsg.Subject = "Secret Santa";
mailMsg.Body = name + ", your target is " + recipient + ". Please spread the holiday cheer with a soft cap of $20! From an automated mail service";
//SmtpClient
SmtpClient smtpConnection = new SmtpClient("smtp.live.com", 587);
smtpConnection.Credentials = new System.Net.NetworkCredential("[email protected]", "password");
smtpConnection.UseDefaultCredentials = true;
smtpConnection.EnableSsl = true;
smtpConnection.DeliveryMethod = SmtpDeliveryMethod.Network;
smtpConnection.Send(mailMsg);
}
Upvotes: 2
Views: 5698
Reputation: 3481
Try following code:
smtpConnection.Credentials = new System.Net.NetworkCredential("[email protected]", "password");
smtpConnection.UseDefaultCredentials = true;
You provide your own credentials for authentication, so you have to set UseDefaultCredentials to false
. Otherwise SmtpClient
cannot authenticate and you get error.
Upvotes: 1