0

How to send a mail outside the network. Currently i'm using the below code:

MailMessage objMailMsg = new MailMessage();
MailAddress FromAddress = new MailAddress("from@testmail.net");
MailAddress ToAddress = new MailAddress("to@testmail.net");
objMailMsg.From = FromAddress;
objMailMsg.To.Add(ToAddress);
objMailMsg.Subject = "Test";
objMailMsg.Body = "This is a test mail";
objMailMsg.IsBodyHtml = true;

int port = 25;
string IPaddr = "10.1.0.125";

SmtpClient smtpClient = new SmtpClient();
smtpClient.Port = port;
smtpClient.Host = IPaddr;
smtpClient.Send(objMailMsg);

On running, I'm getting an exception: Mailbox unavailable. The server response was: 5.7.1 Unable to relay

Where should I change. In code or is it SMTP related?

Ashin
  • 139
  • 3
  • 15
  • Possible duplicate of [Mailbox unavailable. The server response was: 5.7.1 Unable to relay Error](https://stackoverflow.com/questions/15717743/mailbox-unavailable-the-server-response-was-5-7-1-unable-to-relay-error) – PaulF Oct 13 '17 at 10:56
  • relay error says it all - the server you sent to doesnt accept your mails because its not designed to – BugFinder Oct 13 '17 at 10:58
  • Is it a code related issue. or server related (should i contact admin) – Ashin Oct 13 '17 at 11:36
  • More likely the latter. – mjwills Oct 16 '17 at 01:03

0 Answers0