1

The code is embedded in a SharePoint 2010 form.

I am getting an error when trying to send an SMTP email.

Type: SmtpFailedRecipientException, Exception Message: Mailbox unavailable. The server response was: 5.7.1 Unable to relay)

Using a Relay Connector in Exchange 2010. The relay has been setup to allow Anonymous,Exchange Users, Exchange Servers, Legacy Exchange Servers, Partners.

This code used to work on a Exchange 2007. We have temporarily moved to a 2010 Exchange. Since then had the issue. Not quite sure if the code needs to change or missed something on the Exchange 2010 server.

Later this year we will be upgrading to 2019 Exchange.

Any suggestions will be much appreciated.

    public bool SendEmail(string to, string body, string ccd, string reference,string mysubject)
            {
                string CCd = ccd;
                string OurEmail = "HR Forms <ElectronicForms@hb.uk>";
                string subject = mysubject;
                MailAddress From = new MailAddress(OurEmail);
                MailAddress To = new MailAddress(to);
                bool success = false;
                using (MailMessage message = new MailMessage(From, To))
                {
                    message.CC.Add(CCd);
                    message.Subject = subject;
                    message.Body = body;
                    message.IsBodyHtml = true;
                    NetworkCredential loginInfo = new NetworkCredential("", "");
                    SmtpClient smtpClient = new SmtpClient("relay.hb.uk", 25);
                    smtpClient.Credentials = loginInfo;
                    smtpClient.EnableSsl = false;
                    smtpClient.EnableSsl = false;
                    smtpClient.Send(message);
                    success = true;
                }
                return success;
            }

I am getting the following error when trying to send an email.

Type: SmtpFailedRecipientException, Exception Message: Mailbox unavailable. The server response was: 5.7.1 Unable to relay)

RODIHB
  • 11
  • 1
  • take a look at this StackOverflow aricle https://stackoverflow.com/questions/3165721/mailbox-unavailable-the-server-response-was-5-7-1-unable-to-relay-for-abcxyz – Yuri Jul 12 '19 at 12:55
  • 1
    Possible duplicate of [Mailbox unavailable. The server response was: 5.7.1 Unable to relay for abc@xyz.com](https://stackoverflow.com/questions/3165721/mailbox-unavailable-the-server-response-was-5-7-1-unable-to-relay-for-abcxyz) – ivcubr Jul 12 '19 at 14:11

0 Answers0