2
votes

I having problem on sending message on the server. But in my local I can send message to the emails using the free smtp server.

Maybe there's a firewall or localhost is not accepted in the email policy?

Please advise.. thanks!

Code:

//send email
MailMessage objEmail = new MailMessage(new MailAddress(ConfigurationManager.AppSettings["emailAdd"].ToString()), new MailAddress(ConfigurationManager.AppSettings["emailAdd"].ToString()));
objEmail.Subject = "Test";
objEmail.Body = _Message;
objEmail.Priority = MailPriority.High;
SmtpClient SmtpMail = new SmtpClient();
SmtpMail.Host = "localhost";
SmtpMail.Send(objEmail);

Error:

System.Net.Mail.SmtpFailedRecipientException: Mailbox unavailable. The server response was: 5.7.1 Unable to relay for mae@yahoo.com at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, SmtpFailedRecipientException& exception) at System.Net.Mail.SmtpClient.Send(MailMessage message)

2
What email address are you trying to send to, yahoo, hotmail, etc?Kiquenet

2 Answers

3
votes

This blog post answers basically the same question. Assuming you are sending through the IIS SMTP server, you may need to modify the Relay Restrictions to allow relaying from your IP address.

1
votes

Few checks:

  1. Check if your proxy is not blocked if using
  2. Check that your server IP is in white-list, if it is being maintained on mail server
  3. On mail server check if no password is required
  4. Smtp server address is fine