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

Mailbox unavailable. The server response was: 5.7.1 Unable to relay for
private void SendMAil()
        NetworkCredential loginInfo = new NetworkCredential("", "troikainfo");
        MailMessage msg = new MailMessage();
        msg.From = new MailAddress("");
        msg.To.Add(new MailAddress(""));
        msg.Subject = "Demo";
        msg.Body = "Code of vidya";
        msg.IsBodyHtml = true;
        SmtpClient client = new SmtpClient("");
        client.EnableSsl = false;
        client.UseDefaultCredentials = false;
        client.Credentials = loginInfo;

Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


you are trying to send a message using a SMTP server which doesn't allow you to relay (send message which has to be delivered to another mail server). Use SMTP server which belongs to your ISP (and follow ISP's recommendations. ISP usually idetifies its custormers by IP addresses. It can allow relay for authentified users too). Or you can use another SMTP server but it should require another security features like SMTP authentication)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
If the SMTP server will let you log in to authenticate yourself, you can do as tomand suggested.  Here's a link to code for authenticating and sending mail:

the following code worked for me:

Dim mm As New MailMessage(fromaddress, toaddress)
mm.Subject =  "Subject "
mm.IsBodyHtml = True
mm.Body = ""
Dim smtp As New SmtpClient
smtp.Host = ""   'Modify smtp server name as per your requirement
smtp.Port = "25"   'Modify port number as per your requirement

web .config Code :
<network host="" userName="" password="yourpassword"/>

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Email Clients

From novice to tech pro — start learning today.