0

I created a web form that sends out an email. When the email address in the toAddr is for example johndoe@company.com it works, but if I try johndoe@yahoo.com or johndoe@gmail.com it does not work. The email sends only internally.

This the error I get: "System.Net.Mail.SmtpFailedRecipientException: Mailbox unavailable. The server response was: 5.7.1 Unable to relay"

SmtpClient client = new SmtpClient("mail.company.com");
MailAddress toAddr = new MailAddress("johndoe@yahoo.com");
MailAddress fromAddr = new MailAddress("notify@company.com");
String messageText1 = "<h4>Thank you.</h4>";

string messageSubject = "Confirmation";
MailMessage message = new MailMessage(fromAddr, toAddr);

message.IsBodyHtml = true;

message.Subject = messageSubject;
message.Body = messageText1; 

client.Send(message);
Apollo
  • 1,990
  • 12
  • 44
  • 65
  • http://stackoverflow.com/questions/5092235/c-sharp-smtp-email-sending-code-fails-for-yahoo-mail-but-works-fine-for-other-se – reggie Aug 21 '14 at 16:00
  • 1
    Possible duplicate http://stackoverflow.com/questions/3165721/mailbox-unavailable-the-server-response-was-5-7-1-unable-to-relay-for-abcxyz – Samer Aburabie Aug 21 '14 at 16:02

0 Answers0