View Full Version : Newsletter unsubscribe security
05-12-2008, 06:34 PM
I've designed a newsletter feature for my application, and I need to build in an unsubscribe link. What I'm trying to figure out is how to make it secure; in other words, I don't want someone to be able to copy the link and be able to change it to unsubscribe people other than themselves. Every person's e-mail address is pulled from a mySQL database and sent through phpMailer.
So how would you do this? Would you do a hash of their e-mail address and match it somehow? I just need some suggestions to get my mind-wheels turning. Thanks. :)
05-12-2008, 06:42 PM
How about sending another link(when some one click to unsubscribe) to the same mail id (which contains a copy of random number stored in table along with the user id) to confirm the removal of subscription?
05-12-2008, 07:44 PM
Thanks for the suggestion, ab.
FYI, I brainstormed, and I think I came up with a good way of doing this. In the unsubscribe link, I put the client_id (the client who is sending the newsletter), the person_id (of the person the client is sending the e-mail to), and a hash (of the person's e-mail address). On the unsubscribe page, it grabs the client's database, finds the person_id's e-mail address, and attempts to match the e-mail address hash in the link to the hash of the e-mail address in the database. If it matches, it sets that person_id's unsubscribe boolean to 1.
Does anyone see any holes in this method?
05-12-2008, 07:55 PM
Just use a hash of the e-mail, id, person_id, etc. and store it in the database.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.