Sitecore EXM module support the Subscription functionality out of the box. There are 4 standard emails:
- Subscription Confirmation - will be sent after submitting Newsletter Subscription form and will contain a confirmation link with key. After successfull cinfirmation, you will be redirected to the page defined in the EXM Manager Root as a Final Confirmation Page field;
- Subscription Notification - will be sent after confirming your subscription (by clicking on the link in the email which described above);
- Unsubscribe From All Notification - will be sent after unsubscribing from all emails (contact will be put into Global Opt-out List)
- Unsubscribe Notification - will be sent after unsubscribing from current email campaign. (contact will be removed from current subscription contact list).
When unidentified visitor try to open confirmation link, or tried to unsubscribe (by clicking the unsubscribe link in the email), he will be redirected to the Subscription Page which defined in the EXM Manager Root as a Subscription Page field.
We can use the following code for subscribing user:
var recipientId = new XdbContactId(Tracker.Current.Contact.ContactId);
var messageId = new Guid(“6e4ad96c-1856-4bb0-95e2-c35d2e2d0734”);
var isSubscribed = ClientApi.TrySubscribe(recipientId, messageId, false);
You can find more about that there: The Email Experience Manager Client API