View Single Post
08-11-2012, 09:30 PM
fde is offline fde
Status: I'm new around here
Join date: Aug 2012
Location: netherlands
Expertise: php
Software: xampp, cream for vim
Posts: 3
iTrader: 0 / 0%

fde is on a distinguished road


Imo you should use a cronjob which runs a php shell script.

This script set to run monthy in cron, connects to database, grabs the usernames and email adresses from db into array or object.

Then you do something like:
PHP Code:

=" __ " 
$subject 'special code';
$headers 'From:' "\r\n" .
'Reply-To:' "\r\n" .
'X-Mailer: PHP/' phpversion();

foreach (
$users as $user){
$to      =$user['email'];
$message 'Hi here is your special code: '.$uniqspecode;


When using object, its $user->name and $user->email
Make sure this script cannot be accessed directly from the internet, you don't want someone to visit and send out a new batch of codes at every page refresh. One way to prevent this is instead of using <?php and ?>,
PHP Code:
in top of the script. Note you need the PHP CLI properly installed. Another way then cron is to just run the script manually every month via a protected login environment.

The seperator is provided to allow parsing of the specialcode and compare to md5 encrypted usernames, to determine which user it was.