I'm sending a simple mail with attachment using SmtpClient but I get this error:
Mailbox unavailable. The server response was: not local host example.com, not a gateway
System.Net.Mail.SmtpFailedRecipientException: Mailbox unavailable.
The server response was: not local host example.com, not a gateway at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, SmtpFailedRecipientException& exception) at System.Net.Mail.SmtpClient.Send(MailMessage message)
And the code:
public static void CreateMessageWithAttachment(byte[] compressed)
{
// Create a message and set up the recipients.
MailMessage message = new MailMessage(
"[email protected]",
"[email protected]",
"Hello.",
"How are you?");
// Create the file attachment for this e-mail message.
Stream attachStream = new MemoryStream(compressed);
Attachment attachment = new Attachment(attachStream, MediaTypeNames.Application.Octet);
message.Attachments.Add(attachment);
//Send the message.
SmtpClient client = new SmtpClient("123.12.12.123");
// Add credentials if the SMTP server requires them.
client.Credentials = CredentialCache.DefaultNetworkCredentials;
client.Send(message);
attachment.Dispose();
}
Of course the domain and IP is valid in the original code. I have tried using both "localhost" and IP but getting same error. Googling returned 3 results of which the helpful one seems to be in chinese and firewall preventing me from translating it.
Thanks in advance.