Mailbox unavailable. The server response was: 5.7.1 Unable to relay RRS feed

  • Question

  • Hi ,

    I am getting the error whenever I tried to send the email other than company domain "site@mydomain.com

    Mailbox unavailable. The server response was: 5.7.1 Unable to relay Why?

    I tried to send email from asp.net 3.5 page this is my code

    This working fine for my company domain not for other mail like yahoo,gmail or hotmail etc..

    using System.Net.Mail;

    public static void sendMail(string body, string from, string to, string subject)
            string _body = body.ToString();
            string delim = ";";
            SmtpClient MailObj = new SmtpClient("mail.mydomain.edu",25);

            System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
            //string[] addresses = to.Split(new char[] { ';' });
            //foreach (string recip in addresses)
            //    msg.To.Add(recip);
            msg.From = new MailAddress(from.ToString());
            msg.To.Add(new MailAddress(to.ToString()));
            msg.Subject = subject.ToString();
            msg.Body = _body.ToString();
            msg.IsBodyHtml = true;



    Friday, April 29, 2011 5:07 PM


All replies

  • Your problem is not in code, the email server is configured to not allow relay from other domains. If you have mail administrator start with that person.
    Bob - www.crowcoder.com
    Friday, April 29, 2011 5:45 PM
  • Thank you!

    I ck with admin, relay server is turned off to block all other email.

    Any other way to send other emails??

    Friday, April 29, 2011 7:30 PM
  • I think  your only option is to authenticate with the specific provider directly. For instance if you are trying to send mail using foo@gmail.com you will need to use google mail server in the SmtpClient.

    Please also be aware that using this method does not protect your login and it can be intercepted in transit. Please view one of my recent posts for code to use SSL encryption.


    Bob - www.crowcoder.com
    Friday, April 29, 2011 7:40 PM