What is the best way to implement an unsubscribe link for your newsletter?

Tony picture Tony · May 12, 2009 · Viewed 9.4k times · Source

I am thinking that I create a deactivation code put that in the unsubscribe link along with their user id. Then when a recipient of my newsletter clicks the link, I can look up their user id and see if the deactivation code matches.

Does this sound like the best way?

What are some other ways?

Answer

MatthieuP picture MatthieuP · May 12, 2009

You could just use an hashing algorithm to secure the userID (so that nobody can unregister all your DB with a nasty loop).

You'll end up with two params : userID and hash.

The advantage is that you won't need to store any mapping between deactivation code and userID.