I have used SPUtility.SendEmail to send email to users programmatically and it works. However if the user's email is different than the outgoing email domain it returns false. How do I make it work for external users as well? It is an on-premise SharePoint 2013 server.

This code works:

System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
message.To.Add("[email protected]");
message.Subject = "The subject";
message.From = new System.Net.Mail.MailAddress("[email protected]");
message.Body = "This is body";
System.Net.Mail.SmtpClient smtpClient = new System.Net.Mail.SmtpClient("sp.spd.local");
smtpClient.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;

This code returns false if you use gmail but returns true if you use same domain email

System.Collections.Specialized.StringDictionary headers = new System.Collections.Specialized.StringDictionary();
headers.Add("To", "[email protected]");
headers.Add("From", "[email protected]");
headers.Add("Subject", "Test Email Subject");
headers.Add("content-type", "text/html");
string bodyText = "This is the body of my email, in html format.";
Boolean sent = SPUtility.SendEmail(currentWeb, headers, bodyText, true);
  • Hi medes, can you share your code as well
    – SandeshR
    Oct 22, 2015 at 13:04
  • @Medes: Do you found error?
    – D T
    Jan 5, 2021 at 2:23

2 Answers 2


Most probably the problem does not come from the SharePoint configuration, but from the SMTP relay you use. Do you use IIS 6.0 as the local SMTP? Does it then forward the email to an Exchange server or else? The local SMTP relay or the Exchange server configurations have to be investigated first.

  • thanks Evariste, for now I am using my dev environment which is a single server. If I use System.Net.Mail.SmtpClient with SmtpDeliveryMethod.PickupDirectoryFromIis it sends email to external users also.
    – Medes
    Oct 22, 2015 at 12:59
  • That probably means your local SMTP relay (IIS 6) rejects SharePoint when it tries to connect it to send to an external user (while droping a file in the pickup folder is OK). So, I'd look at the SMTP config in IIS 6 management console, to check if domains other than local is allowed.
    – Evariste
    Oct 22, 2015 at 13:24
  • I looked at smtp, every thing looked ok. I am not a smtp guru mybe something I am missing. Which part do I need to configure?
    – Medes
    Oct 22, 2015 at 15:46
  • Among other things: right-click on "Default SMTP Virtual Server", "Properties", "Access" tab, "Relay..." button, ensure your SharePoint server IP is allowed to relay. Also, in the "Delivery" tab, "Outbound security", check whether the relay you want to use for external connections is correctly set. You need a "real" SMTP server to go out, the one used for your organization.
    – Evariste
    Oct 22, 2015 at 18:14
  • I did the changes but still it returns false, I think it must be a SharePoint configuration because when I drop an email file to the pickup folder it sends it o my gmail.
    – Medes
    Oct 23, 2015 at 7:12

This is most likely going to be a configuration issue on your SMTP server. When you send the email, look for EventID aiba9 in the ULS log (alternatively, filter by the Category E-Mail). This should provide you with the error message that you're most likely receiving from the SMTP service.

As others have pointed out, in order for you to relay, you'll need to allow anonymous relay (but perhaps restricted by IP address which would be best practice) since SharePoint Server 2013 cannot authenticate to the SMTP server.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.