0

I can send emails via the SharePoint SendEmail Utility REST API and set the Sender and Reply-To headers to facilitate communication between the recipient of the email and the user who triggered the sending of the email. These headers are correctly set and reflected in the recipient's email client when sent by on-premises instances of SharePoint 2013 and SharePoint 2016. When I send an identical request to SharePoint Online, the Sender and Reply-To headers are overwritten by the time they arrive in the recipient's email client.

The following is sample code used in SP2016 on-prem and SPO. The email addresses have been anonymized, but the true email addresses are associated with active SharePoint users on the site.

var sendTestEmail = async () =>
{
  const getDigest = async () => (
    (await (
      await fetch(
        _spPageContextInfo.webAbsoluteUrl + "/_api/contextinfo",
        { headers: { Accept: "application/json;odata=verbose" }, method: "POST" }
      )
    ).json()).d.GetContextWebInformation.FormDigestValue
  );
  var body = {
    "properties": {
      "__metadata": {
        "type": "SP.Utilities.EmailProperties"
      },
      "AdditionalHeaders": {
        "__metadata": {
          "type": "Collection(SP.KeyValue)"
        },
        "results": [
          {
            "__metadata": {
              "type": "SP.KeyValue"
            },
            "Key": "From",
            "Value": "Paul******@******.com",
            "ValueType": "Edm.String"
          },
          {
            "__metadata": {
              "type": "SP.KeyValue"
            },
            "Key": "Reply-To",
            "Value": "Paul*****@******.com",
            "ValueType": "Edm.String"
          },
          {
            "__metadata": {
              "type": "SP.KeyValue"
            },
            "Key": "Sender",
            "Value": "Paul*****@******.com",
            "ValueType": "Edm.String"
          },
          {
            "__metadata": {
              "type": "SP.KeyValue"
            },
            "Key": "X-SharePoint-Site",
            "Value": "https://*******.sharepoint.com/sites/**************",
            "ValueType": "Edm.String"
          }
        ]
      },
      "BCC": {
        "results": ["Paul*****@******.com"]
      },
      "Body": "<html><body><font face=\"Segoe UI\">\n<p>Paul Rowe,</p>\n<p>You are the recipient of a new Notification from Paul Rowe.<p>\n<p>I included the following note.</p>\n<blockquote>This is a test. This is only a test.\n\n2023-01-13 14-28</blockquote>\n<!-- No action necessary for Notifications without files. -->\n<p>Regards,<br />Paul Rowe</p>\n</font></body></html>",
      "CC": {
        "results": ["Juan*****@******.com"]
      },
      "Subject": "XYZ, Inc. Correspondence: New Notification",
      "To": {
        "results": ["Paul*****@******.com"]
      }
    }
  };
  return fetch(
    _spPageContextInfo.webAbsoluteUrl + "/_api/SP.Utilities.Utility.SendEmail",
    {
      body: JSON.stringify(body),
      headers: {
        Accept: "application/json;odata=verbose",
        "Content-Type": "application/json;odata=verbose",
        "X-RequestDigest": await getDigest()
      },
      method: "POST"
    }
  );
};
sendTestEmail().then(console.log).catch(console.error);

The following headers (anonymized) were extracted from the email received when sent by SP2016 on-prem.

Reply-To: Paul*****@******.com
Sender: Paul*****@******.com
X-SharePoint-Site: https://sharepointservices.******.com/sites/**************
SharePointSiteId: {00000000-0000-0000-0000-000000000000}
From: MIS Team <no-reply@******.com>
To: Paul*****@******.com
CC: Juan*****@******.com
Date: Wed, 18 Jan 2023 17:16:06 -0500
Subject: XYZ, Inc. Correspondence: New Notification

The following headers (anonymized) were extracted from the email received when sent by SP Online.

Date: Thu, 19 Jan 2023 15:47:25 +0000
Subject: XYZ, Inc. Correspondence: New Notification
Sender: MIS Team <[email protected]>
Reply-To: [email protected]
X-SharePoint-Site: https://*******.sharepoint.com/sites/**************
SharePointSiteId: {00000000-0000-0000-0000-000000000000}
To: Paul*****@******.com
Cc: Juan*****@******.com
From: MIS Team <[email protected]>

Note that SharePoint Online has overwritten the Sender and Reply-To headers.

  • Where is this change in behavior documented?
  • How can a server admin prevent SharePoint Online overwriting the Sender and Reply-To headers?

1 Answer 1

1

In SharePoint Online, emails sent from the SharePoint service always use the [email protected] email address. In Microsoft's documentation, it notes that this also affects custom messages:

The features that are affected by this change include the following:

  • Message sharing if the user does not have an Exchange Online mailbox
  • Access Requests if the user does not have an Exchange Online mailbox
  • SharePoint Newsfeed notification messages
  • Custom messages that are generated by workflows if the From address was changed to a different address

Information about changes to the address that is used to send notification email messages from SharePoint

2
  • Thank you for sharing this link. I'd seen it before. I didn't realize it applied because I see the same behavior even when I don't set the From header. Is there any way to ask SPO or O365 to honor my Reply-To or Sender headers?
    – Paul Rowe
    Jan 22, 2023 at 5:22
  • 1
    I don't believe so. Much of the SMTP configuration was always part of SharePoint Server farm administration. In the case of SPO, your tenant is only one of many tenants in a farm controlled by Microsoft. Jan 22, 2023 at 16:42

Your Answer

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

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