I have an MVC 3 app and everything I try on my new hosting provider ends up throwing this exception:
Server Error in '/' Application. Mailbox unavailable. The server response was: Authentication is required for relay
I tried using the code from
How can I make SMTP authenticated in C#
which has many up votes, but I still get the exception.
My host has the typical panels that let me create mail accounts. I'm not sure about creating NetworkCredentials, what do I use as the User Name and password? What I've been using is the email address and the password for the email account.
Here's my code:
public static void sendMail(Joiner request) {
SmtpClient smtpClient = new SmtpClient();
NetworkCredential basicCredential =
new NetworkCredential("garbage@stopthedumpcoalition.org", "REDACTED");
MailMessage message = new MailMessage();
MailAddress fromAddress = new MailAddress("garbage@stopthedumpcoalition.org");
smtpClient.Host = "mail.stopthedumpcoalition.org";
smtpClient.UseDefaultCredentials = false;
smtpClient.Credentials = basicCredential;
message.From = fromAddress;
message.Subject = "Join the Coalition request from - " + request.FirstName + " " + request.LastName;
//Set IsBodyHtml to true means you can send HTML email.
message.IsBodyHtml = true;
message.Body = "Name: " + request.FirstName + " " + request.LastName + "<br>"
+ "EMail: " + request.Email + "<br>"
+ "Wants to Volunteer: " + request.Volunteer.ToString() + "<br>"
+ "Organization: " + request.Organization + "<br>"
+ "Wants to become a Partner: " + request.Partner.ToString() + "<br>"
+ "Comments: " + request.Comments;
message.To.Add("nivram509@gmail.com");
smtpClient.Send(message);
}