lau Posted May 21, 2008 Share Posted May 21, 2008 Hi all, I want to create an 'Unsubscribe' link in the e-mails I'm sending out. If the person receiving the e-mail no longer wants to receive e-mails from me, they click the 'Unsubscribe' link in the e-mail which will be something like this: http://www.mysite.com/[email protected] So upon click this link they will be taken to a page that says, do you wish to stop receiving these e-mails - Yes / No? When the user clicks 'Yes', I need to save the e-mail address from the link in a text file. Could anyone tell me how to do this using php? Thanks, Laura Link to comment https://forums.phpfreaks.com/topic/106595-unsubscribe-e-mail/ Share on other sites More sharing options...
phpzone Posted May 21, 2008 Share Posted May 21, 2008 Something like the following, I just typed this in off-hand so there could be errors, but I'll let you do some work on it Make your directory the unsubscribe.txt sits in writable. <?php define( 'UNSUBSCRIBE_FILE', '/home/phpzone/wwwroot/files/unsubscribe-' . date('Y-m-d') . '.txt'); $email = $_REQUEST['email']; $fp = fopen( UNSUBSCRIBE_FILE, 'a+' ); if ( $fp ) { fwrite( $fp, $email, strlen($email) ); fclose( $fp ) print <<<_THANKS <p>Thank you, we will remove your address from our database within 48 hours. If you continue to receive emails after this time please contact us on 00000 00000 00000</p> _THANKS; } else { print <<<_ERROR <p>There was an problem unsubscribing you, to report this error and request removal via telephone, please ring 000000 00000 0000</p> _ERROR; } ?> Link to comment https://forums.phpfreaks.com/topic/106595-unsubscribe-e-mail/#findComment-546348 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.