sendgrid / wordpress

SendGrid plugin for WordPress
51 stars 64 forks source link

Confirmation textarea has no way to insert formatted unsubscribe link? #46

Open codesman opened 7 years ago

codesman commented 7 years ago

The "Signup email content" textareas in the settings don't appear to offer a way to customize placement of the unsubscribe link that is required by CAN-SPAM/SendGrid and the result is that the link is automatically inserted at the very end of the email and you get something like this:

unsubscribe-link-problem

That's not very professional looking, my clients don't want them to go out that way.

The %confirmation_link% template tag is working to insert the proper confirmation URL. Is there a way to get the unsubscribe URL as well, so the SendGrid app won't automatically insert whatever it wants at the end of the email?

I've looked in the SendGrid control panel and couldn't find an unsubscribe URL anywhere but in a builder tag and those don't work in this plugin. Is it possible to manually construct an unsubscribe URL?

sebastianplesciuc commented 7 years ago

@codesman Can you give us an example of how you send these emails? Do you do it programmatically?

You should be a aware that there is a setting in your SendGrid account on this page: https://app.sendgrid.com/settings/tracking called Subscription Tracking. If active, it will add the unsubscribe link to the bottom of all email content.

For more details on how to customize this link for subscription tracking refer to this documentation: https://sendgrid.com/docs/Classroom/Track/Unsubscribes/unsubscribe_via_subscription_tracking.html Specifically the "I don’t want my unsubscribe links at the bottom!" section.

If you're using ASM Groups, refer to this documentation: https://sendgrid.com/docs/User_Guide/Suppressions/recipient_subscription_preferences.html#-Manage-Email-Preferences

If you need to set this tracking programmatically only for some emails, you can use the SendGrid Email object as the $headers param in wp_mail like this:

$email = new SendGrid\Email();
$email->smtpapi->addFilter('subscriptiontrack', 'enable', 1);
$email->smtpapi->addFilter('subscriptiontrack', 'replace', '%subtrack%');
wp_mail('test@test.com', 'test email', '<p>content1</p> <p> <a href="%subtrack%"> click here to unsubscribe </a> </p> <p>content2</p>', $email);