I wrote this class for a friends company and for the sake of convienance they have agreed to let me release it as public domain which means I can also release it here
It is a class that helps you to produce/send/confirm those "Verifiy your email address" emails that most websites send nowadays.
It allows you to add an email address / confirmation code to the datastore, it then sends the confirmation email, then provides a method for you to verifiy the confirmation code when the link is clicked.
By default it supports a MySQL datastore for storing your email addresses but can be easily extended to support other formats. I've added (untested) support for Sqlite to give you an example of how to extend it.
From the readme.txt:
Email Verification Class
Written by Alan Wagstaff
Donated to the Public Domain
This class allows you to send confirmation emails to your users when they register asking them to click on a link to confirm their email address. It then updates their email address record to indicate it is confirmed.
It supports different types of datastore, the provided one being MySQL.
The class Email_Verification_Storage_Abstract can be extended to support other systems (ie, Sqlite, CSV) as required - see Email_Verification_Storage_Mysql for an example.
The MySQL table it uses to store the email addresses should look something like:
You will need to create this yourself or more likely, merge support into your existing users table to avoid duplication.
An example email template is included in "classes/email_template.txt" - edit it to suit your needs. If you want to parse more placeholders (ie, users first name), then the code for it can be found in "classes/Email_Verification.php" around line 288.
One thing to watch for - this class throws a lot of exceptions if it runs into a problem (see Exceptions.txt for a full list) so be sure to catch them in your code - if they pass by un-caught your script will die rather spectacularly.
This code is donated to the public domain. For those young enough to not remember the days before GPL, MIT, BSD and all the other open source licences, the "Public Domain" means that you can do whatever you wish with the code, including stealing it and claiming you wrote it if you so desire.
This code is completely unsupported but I'll try to answer any questions that you have - email me at email@example.com or visit http://www.talkphp.com/ and ask the friendly PHP community for help
It should generally work but if you run into any problems, feel free to ask
If you are particularly bored, feel free to use/abuse/improve the class. In particular, it could do with some refactoring and I did intend to add support for CSV and XML datastores but didn't get around to it.
Hope it's useful for someone
The Following 3 Users Say Thank You to Alan @ CIT For This Useful Post: