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?
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.