2

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 [email protected] at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, SmtpFailedRecipientException& exception) at System.Net.Mail.SmtpClient.Send(MailMessage message)

1
  • What email address are you trying to send to, yahoo, hotmail, etc? Commented Feb 13, 2015 at 9:39

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

2 Comments

where are you trying to send from and where is the smtp server running? this post also has more suggestions: forums.iis.net/p/1039915/1901768.aspx
What email address are you trying to send to, yahoo, hotmail, etc? If you're not getting the relay error anymore then the first email server you are sending to is accepting the message. The problem is most likely that your email server cannot send the message to the next server in the chain. If you turn on logging for your SMTP server you should be able to get some more information as to what's happening. Update your question with whatever you find from the logs.
1

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.