Hi,
I am not able to send emails to external domain addresses like '[email protected]' using the code below.
SmtpClient smtpClient = new SmtpClient(smtpMailServer);
smtpClient.UseDefaultCredentials = true;
smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
smtpClient.EnableSsl = true;
//Sending mail.
smtpClient.Send(mailMessage);
I get an exception -
Mailbox unavailable. The server response was: 5.7.1 Unable to relay for [email protected]
If I change the DeliveryMethod to -
smtpClient.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;
I am able to send the emails on my local machine. But it fails on the production site with an exception -
Cannot get IIS pickup directory
Can you please suggest me what to do?