<?php
class massMail
{
var $subject = array( );
var $body = array( );
var $to = array( );
var $attachment = array( );
var $boundary = '';
var $header = '';
var $sender = ''
$subject = $this -> getSubject( "{$vars['class']}");
mail( $mail, $subject, '', "{$top}{$body}\n{$tail}");
}
$this->to = array(); //can build up the to list and send another batch
} //function send()
} //class massMail
/**
* massMail Test Script
*
**/
//dummy script to get the body of each email type. Typically it would query the database
function getFUBody($type)
{
if ($type == 1) $output = 'hello world<br>My Id is {LISTID}<br>bye now';
elseif ($type == 2) $output = 'That was fun<br>My Id is {LISTID}<br>bye now';
elseif ($type == 3) $output = 'third time lucky<br>My Id is {LISTID}<br>bye now';
else $output = 'Last campaign message<br>My Id is {LISTID}<br>bye now';
$mail = new massMail('Senders name','support@mysite.com');
//preload each email type for the campaign
for($i = 1; $i < 5; $i++)
{
list($subject, $body) = getFUBody($i);
$mail->setSubject("{$i}", $subject);
$mail->setBody("{$i}", $body);
}
//add each address you need to email and each of the variables embedded in the email body
//this example includes a database id for the unsubscribe process
//but could include any number of personalization variables.
$mail->setTo('sarah@mysite.com', array('class' => '2','{LISTID}' => '9049'));
$mail->setTo('joe@mysite.com', array('class' => '2','{LISTID}' => '851'));
//send
$mail->send();
matthew waygood wrote :1133
When you initialise the class, you are setting the from email address. When you send() the email you are also adding a second FROM.
I liked the personalising of the emails by doing a mail-merge with some data, but it would be nice to set some default values incase you omit them. This would then remove the {mailmerge value} codes too.
ie
Dear Bob, Dear Claire, Dear {customer_name}
with a default customer_name as customer you would get
Dear Bob, Dear Claire, Dear customer
you could also set defaults to empty for other values, such as passwords.
It would also be nice to see a clear send list function. This is to prevent the dataset growing too big before sending, allowing us to repeatedly load list, send and clear. We wouldnt need to recontruct the email again for a second set.
This example used on a dataset of 100000000 people wouldn`t overload the memory too much. I know execution time is a consideration, but if you use this in part of a cron job, you would have no worries of a system crash.
Jose Santos wrote :1134
Hello !
I`ve develloped an system to send mass mail, using an csv file to subscribe / unsubscribe, ...
And with csv files you made to have more information (example: "name","email","from","city","phone" ...)
It dont have limit, and you can optimize the csv class to accept any parameters.
To send an mass mail, only get the "email" column of all lines of this file (csv).