EasyPhpMassEmail Class

The EasyPhpMassEmail class is intended for websites that need a simple solution for sending many emails and do not have access to the PEAR packages for sending mass emails.

The EasyPhpMassEmail class works with the standard PHP mail() command, which is not intended for sending out mass emails as it will establish a new SMTP connection for every email (the professional packages establish one connection and send all the emails at once). Another issue with the mail() command is that it will just stop working after it sends a certain amount of emails (or the script will time-out).

The EasyPhpMassEmail class sends the emails in batches and relies on an email queue page which reloads after each batch. By doing so it is possible to send large amount of emails without problems using the mail() command and have a progress indication at the same time. Each recepient will receive an individual email, no other email addresses are exposed.

The allowable batch size and total amount of emails you can send depend on your webserver or email hosting provider. Feel free to post your successes in the comments section below!

The example files in the package demonstrate the use of the class. Upload all three files to a directory on your webserver and open the page 'mass_email_example.php', click the start link and you will see the class in testmode with its progress indication.

Support EasyPhpMassEmail by booking your next hotel through the link below:

Booking.com

Success!

The API:

include_once('easyphpmassemail.class.php');
$massemail = new easyphpmassemail;

Options / Commands:

$massemail -> Emailto             = array()     // The array containing all the email addresses
$massemail -> Subject             = (string)    // The subject of the email
$massemail -> Headers             = (string)    // The headers for the email
$massemail -> Message             = (string)    // The message body of the email
$massemail -> Batchsize           = (int)       // The batch size for sending emails (depends on server)
$massemail -> Testmode            = (boolean)   // Run in test mode
$massemail -> Preparemail()       = (function)  // Prepare the mass email session, returns true upon success
$massemail -> Sendemails()        = (function)  // Send a batch of emails, returns false upon completion
$massemail -> Progress(string)    = (function)  // Return the progress indicator, 
                                                   '%' returns percentage completed (string)
                                                   'r' returns emails remaining (int)
                                                   't' returns total emails left (int)
$massemail -> Failed()            = (function)  // Returns an array with emails that failed (mail command)
$massemail -> Cleanup()           = (function)  // Cleanup when you are done, returns true upon success

 

AttachmentSize
easyphpmassemail.zip5.13 KB