I'm currently using PHPMailer to send out an email to a mailing list, however I am looking to create an unsubscribe function because I cannot in good conscience not give the option.
The only problem I'm facing is doing it in a safe manner. What I've had in mind so far was to add an href back to my website that would link to a page like http://example.com/unsubscribe.php?email=useremail@test.com but with this method anyone can delete any email they want, or delete the entire mailing list. I'm not sure how I can bypass this issue. My MySQL database only contains a unique email ID which is just their position in the database (the first email added has an ID of 1 and the second has an ID of 2 and so on) and column for the email address itself.
I would do something like this
http://example.com/unsubscribe.php?email=useremail@test.com&token=XXXXXXXXXXXXXXX
$_GET["token"] = hash_hmac('sha256', $email.$email_id, $site_salt);
if token valid then process subscribe.
P.S. I'm not sure why you got a downvote by my guess is because you didn't realize you were legally required to provide an unsubscribe.