Jump to content

Help with creating an Unsubscribe PHP page.


nootkan

Recommended Posts

I am just learning php and found this solution online but it isn't working right for me.  The email link in the body isn't sending the recipients email address, it is sending the example email address.   I have changed the first example email address to my own.  I know I should be replacing the second example email address with something else but not sure with what.  I tried replacing useremail@example.com with just "email" and $email but neither worked. The php page works fine with the exception of not emailing me with the email address that wants to unsubscribe. I don't have a mailing list this is just for my regular emails that I send out to conform with spam rules.  Can someone help me out?

<a href="http://www.example.com/unsubscribe.php?email=useremail@example.com">Click to Unsubscribe</a>
<?php
mail("myemail@mydomain.com","unsubscribe", $_GET['email']);
echo "You have unsubscribed from Domain Name";
?>
Link to comment
Share on other sites

You need to write a script that presents an input form to the user where he will type in his address. The form's submit button should take you to the emailing script where it will retrieve the $_POST values from the form that you want the user to provide. If the values are correct then you build the email body and the subject and the headers (very important!) and call the mail function.

 

Try reading the php manual for mail() if you must use that. There are better mail packages out there but you seem to be at a very early stage of development.

 

Of course if you have already done this then it would have been nice if you posted that (in the proper forum tags) so we could further help you.

 

PS - I have no idea what that anchor tag is for.

Link to comment
Share on other sites

Thanks but as I said I'm not wanting to create a list for users to sign up to. I just want to conform with the spam rules that gmail, hotmail and yahoo etc require when sending normal emails to friends and family.  They have all told me that even normal emails have to have an unsubscribe link in the body for them to allow me to email to their users.  Most of my family and friends use gmail or hotmail and are not receiving my emails.  I have corresponded with hotmail and gmail and was told this by them. Is this not true?

 

PS I use thunderbird as my email client.

Edited by nootkan
Link to comment
Share on other sites

Perhaps you can forget about the tech stuff for a moment and just explain the situation in plain English.

 

So you are sending e-mails to your friends and family, and now you think you need an unsubscribe feature in those e-mails? Bollocks. Either you've completely misunderstood what the providers are actually saying (a link would be helpful), or somebody is pulling your leg.

Link to comment
Share on other sites

What I gather from his post is... he has an email list of friends and family that are all using either yahoo, gmail, or hotmail.  Those three companies require a "unsubscribe" option or his outbound emails immediately go to their spam folders instead of receiving them.

 

I'm not sure why you can't just put at the bottom of the email an HTML link with unsubscribe (even if it does nothing) and prevent it from being flagged as spam (granted I don't know that's true).

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.