James Cridland

Fixing Sendy’s List-Unsubscribe headers

Sendy is a very good self-hosted mail system, and does a good job of replacing Mailchimp or equivalent, dramatically cutting costs.

When you make a list, you can set your “Unsubscribe behavior” to be “Double Opt-Out”. “Double opt-out” is a good thing. It means that when someone follows a link from your email, it asks them “are you sure?” and gives them a button to confirm. That means that a virus checker following links in incoming mail won’t inadvertently unsubscribe users.

However - this breaks behaviour from the new Gmail and Yahoo mail requirements of a “one-click unsubscribe link”. Hit the unsubscribe button in Gmail, and the Gmail app will invisibly call the unsubscribe page - but won’t see that there’s a link to click. Your users will become angry that “I’ve tried to subscribe but you’re still sending me the emails”.

Here’s how to fix that

You’ll want to edit the code on your server. Caveat: this is fiddling with the code of your Sendy installation. You’re on your own - neither Sendy nor I can give you any help. Further, updates to Sendy will revert these changes.

So, as long as you understand that…

You want to edit unsubscribe.php

Above //get variable you want to add…

	//kludge to handle one-click unsubscribes until this is properly fixed
	//for you if you use double opt-out only
	if(isset($_POST['List-Unsubscribe'])) {
		if (strtolower($_POST['List-Unsubscribe'])=="one-click") {
			//This is someone wanting to unsubscribe.
			header('Location: '.$_SERVER['REQUEST_SCHEME'].'://'.$_SERVER['SERVER_NAME'].'/'.$_SERVER['REQUEST_URI'].'&confirm'); exit;
		}
	}

	//get variable

And you’re done

No changes to your emails, but the unsubscribe link will work in email apps like Gmail without any trouble.

I’ve submitted this code to the developer of Sendy so hopefully this will be in a forthcoming release.