Forum Moderators: coopster
I was recommended phpMailer which seems to offer everything I needed but I could not get it to connect (via SMTP) to the remote mail server I am using.
I then tried htmlMimeMail which also did everything I needed. I got it up and running, but when I tried to loop through the recipents addresses adding each recipients name to the body of the email the inbuilt function could not execute fast enough to keep up with the loop. Hence emails were sent to each recipient but each had the same name in the body, the first in the array.
Can anyone help. I just need a simple way of connecting to a remote mail server and send out individualised emails to multiple address.
Thanks.
$name = 'Fred,Brett,Azam';
$name_add = ' alexh@lewispr.com,alexh@lewispr.com,alexh@lewispr.com';
$name_pieces = explode(",", $name);
$add_pieces = explode(",", $name_add);
$res = count($name_pieces);
//echo $res;
$i = 0;
while ($i<$res){
$body_mid = "<p>Dear " . $name_pieces[$i] . "</p>";
$body = $body_start . $body_mid . $body_end;
echo $body;
//echo $add_pieces[$i];
//$mail->setHtml($body, $altbody);
//$result = $mail->send(array($add_pieces[$i]), 'smtp');
$i++;
}
From the docs:
API docs
ŻŻŻŻŻŻŻŻ
Only public methods are documented. All properties are considered private except for
is_built, which is a boolean and determines whether the message is built or not. This
can be reset after sending to false, to force rebuilding if sending multiple times.
If the content of the message doesn't change, rebuilding shouldn't be necessary.
Looks like you need to reset is_built