A PHP class to send emails individually to a list of addresses
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


PHP Mailer

This is a simple PHP class for sending emails individually to multiple recipients in PHP.

The Mailer class can also add the greeting for you, in the form "Dear [Name]".

To use it simply edit sendEmails.php - it's pretty self explanatory:


// Message config
$fromAddr    = '"Joe Bloggs" <joe@example.com>'; // OR simply 'joe@example.com'
$subject     = 'An email about something';
$message     = 'Guess what? I just sent you an email!'; //  OR file_get_contents('message.txt')
$addGreeting = true; // Whether to add a 'Dear ...,' line to the top of the email
$recipients  = array(
    'joe@example.com', // This will appear 'Dear Sir/Madam,' (if $addGreeting == true)
    'Joe' => 'joe@example.com', // This will appear 'Dear Joe,'

// Set the mailer going
$mailer = new Mailer($message, $recipients, $subject, $fromAddr, $addGreeting);

Then to actually send the email just run the following from a command prompt at the root of the project:


The script will output its progress to the command prompt (or whatever STDOUT defaults to).