Opt in email list can be developed by asking users to subscribe to your newsletter. Here users have to add their email address to the list. To verify the ownership of the email address one confirmation email will be posted to subscribed email address of the user.
This script will have two parts.
Part 1 : Registering the user and verification of email address
Part 2 : Managing user and posting of newsletters.
Features of the Newsletter script
Visitor will submit email address and script will check with existing list for matching email record.
If the visitor is previously subscribed and verified email address then system will display message saying 'not required to subscribe again'
If the visitor is previously subscribed and failed to verify email address then script will display message saying the same and give a link to resend the verification mail.
If any unknown email address (previously not joined or confirmed ) try to confirm then system will not allow them
Each verification email will have a link to visit for verification by user.
Within 300 seconds ( can be adjusted ) user needs to confirm subscription by visiting the confirmation link.
Demo of subscribing to newsletter
You can test by submitting your email address and you will get confirmation mail in your inbox. Then by clicking the verification mail you can confirm subscription.
However this is demo only and not our newsletter box, so we will be deleting or sending you the delete link. Demo for Admin area is not available , however you can install and check at your end. Note that this is for your learning only and this is not to be used for any spamming or any other activity.
Displaying form to collect email address
One simple textbox with a button is to be provided for the user to enter their email address. Here the button will trigger one JavaScript function ajaxFunction() to carry the email address to another script file subscribeck.php by using Ajax.
From subscribe.php page we will be sending two data , one is todo and other one is email to subscribeck.php page by POST method ( using Ajax ).
Confirming the email address
Confirmation email will have one link on the body of the email address. Once the user click the link or visit the URL. The script will read unique id , email and random number from the link and match the same with the record. The record will have date and time stored so the matching record will be checked within 24 hours of subscribing. If the record matches with the data provided by the user Link then the email address will be marked as confirmed or subscribed email address.
Posting of newsletters is discussed in Part II. At the bottom of each newsletter there will be one link for the user to click and visit a page at site to un-subscribe from the list. While un-subscribing we will bit liberal and only check for matching email address and unique id associated with the email address.
One sample link for unsubscribing looks like this.
Thank you. This worked. It was simple to copy paste (install), and it was what I was looking for. This is the first time I've not used a CMS and with a little extra courage I think I'm going to make an entire site from scratch.
malik
09-03-2015
it said Error!: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES)
What to do?
mehran
12-03-2015
Hi, Thank you for this useful script
but one question!
How I can send email as HTML Content. in current case my content send as simple text
thank you,
smo
13-03-2015
Hi Malik
Open the config file and enter correct userid and password for your database connection.
zibx
01-04-2016
Does this script allow to manually add email addresses?
smo1234
07-04-2016
Adding manually is not included. This can be added within Admin interface. You have to decide on going for email address confirmation or not.