Mailbox unavailable. The server response was: 5.7.1 Unable to relay for abc@gmail.com

asp.netsendmailsmtpclient

I am using the below code;
One of the following points could be the reason of the error, but I don't know;

1-The application is on development machine
2-The smtp ip is hosted on the server while app is running on localhost

I am getting this error "Mailbox unavailable. The server response was: 5.7.1 Unable to relay for mhtbusoum@gmail.com";

 Dim message As New MailMessage
 message.From = New MailAddress(Strings.LCase("mhtbusoum@mysite.com"))
 message.To.Add("mhtbusoum@gmail.com")
 message.IsBodyHtml = True
 message.Priority = MailPriority.Normal
 message.Subject = ("Testing SmtpClient email sending")
 message.Body = ("It is to test the email sending without any password")
 Dim client As New SmtpClient("mailSending.actualSite.com", 25)
 client.UseDefaultCredentials = False
 client.Send(message)

Best Answer

When using localhost as mail server, the server will block any e-mail address that is not hosted in localhost.

To relay another e-mail address from other server, you will need to configure the IIS Server to grant the permission.

See this post for configure the relay permissions.