The unsubscribe options
When you use the default email campaign templates in EXM, the email messages you send contain two links that allow recipients to unsubscribe from future email campaigns:
-
Unsubscribe – the contact unsubscribes from the current email campaign. This points to
/sitecore modules/Web/EXM/Unsubscribe.aspx
on the content delivery server. -
Unsubscribe from all – the contact unsubscribes from all your email campaigns. This points to
/sitecore modules/Web/EXM/UnsubscribeFromAll.aspx
on the content delivery server.
The actual links in the email message link to /sitecore modules/Web/EXM/RedirectUrlPage.aspx
.
When a contact clicks an unsubscribe link in an email message, the following happens:
-
In the httpRequestBegin pipeline, EXM adds the OnHttpRequestBegin pipeline processor and performs the following tasks:
-
Decrypts and validates the query string.
-
Gets the message ID and contact identifier from the query string.
-
Saves a reference to the message and the contact and other data to
Sitecore.Modules.EmailCampaign.Core.ExmContext
so that it can be used throughout the entire time of the request.
-
-
The
RedirectUrlPage.aspx
executes theRedirectUrl
pipeline that redirects toUnsubscribe.aspx or UnsubscribeFromAll.aspx
. -
The
Unsubcribe.aspx
and theUnsubscribeFromAll.aspx
files do the following:-
Use the ExmContext to validate that the request is valid, for example, that the request has a contact ID and a message ID.
-
Register the Unsubscribe from email page event.
-
Verify the contact's subscriptions: If the contact is already in the global opt-out list or not subscribed to any of the included lists, EXM redirects the contact to the Already Unsubscribed Page that is defined on the manager root.
-
If the contact is on a list that they must be unsubscribed from, EXM does not unsubscribe them from the list immediately. Instead, EXM delegates the unsubscribe task to the Content Management (CM) server via the UnsubscribeMessagesBus messaging bus. If the Final confirmation page is specified on the manager root, EXM redirects the contact to that page, otherwise it redirects the contact to the front page of the website.
-
When the CM server has handled the unsubscribe, it calls the Sitecore.EmailCampaign.Cm.SubscriptionManager.Unsubscribe(ContactIdentifier contactIdentifier, Guid messageId, bool fromAll)
method.
This method loads the contact and loads the message item. Then, depending on whether it is an unsubscribe or an unsubscribe from all request, the method performs the following:
To unsubscribe the contact from all email campaigns:
-
The method adds the contact to the global opt-out list defined on the manager root related to the message item.
-
The method calls the
UnsubscribeFromAllEvent
pipeline.
To unsubscribe the contact only from the current campaign:
-
The method unsubscribes the contact from the included contact list in the email campaign and makes sure that EXM sends an unsubscribe notification for each unsubscription. Then it calls the
UnsubscribeEvent
pipeline. -
If the contact could not be unsubscribed from any of the included lists or if any of the included lists are segmented lists, the method adds the contact to the global opt-out list.
If the message type is Automated message, nothing happens.