Forum Moderators: coopster

Message Too Old, No Replies

Mail / Unsubscribe link

How to insert an unsubscribe link in mail

         

afridy

1:42 pm on Sep 5, 2006 (gmt 0)

10+ Year Member



Hello

Normall the newsletters we receive have a link placed at the bottom saying "Click Here to unsubscribe". When we we click we taken to the senders website and appear "You have successfully unsubscribed." .

Now my question is how do we take the email address from the mail to the php script? .
Do i need to put a form or a php script in the mail?

pls...

Gian04

1:46 pm on Sep 5, 2006 (gmt 0)

10+ Year Member



As far as I know you cant take the email address from the email, the email address is already linked to the unsubcribed link during the time it was sent.

barns101

3:45 pm on Sep 5, 2006 (gmt 0)

10+ Year Member



The above answer is correct. When sending your email you must send a slightly different mail body to each subscriber, inserting their email address into the unsubscribe link, something like this:


<?php
// You've already pulled the details out of your database and started a while() loop to send each email
{
$mailbody = "Your text<br><br><a href='http://www.example.com/unsub.php?email=$row[email]'>Unsubscribe here</a>";
mail($row[email], "Subject", $mailbody, "From: You <you@example.com>");
}
?>

Hopefully that'll give you some idea of what to do. :)

jatar_k

4:34 pm on Sep 5, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



if the email is stored in a db then you should have some type of unique identifier for that person in your table. I would suggest using that identifier appended to the unsubscribe link, as opposed to using the actual email address in the email.