Forum Moderators: coopster

Message Too Old, No Replies

sending individualised emails from a remote server

         

alexh

11:37 am on Dec 30, 2003 (gmt 0)

10+ Year Member



I have been trying for several days to develop a mass email system which can handle HTML content, can mail out to multiple addresses and where I can individualise the content using each recipient's first name (Dear John).

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.

slade7

2:35 pm on Dec 30, 2003 (gmt 0)

10+ Year Member



Dude, I have never done this, but judging from the looks of my inbox, it can't be that complicated.

mogwai

2:36 pm on Dec 30, 2003 (gmt 0)

10+ Year Member



Hi,

"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. "

Sounds like there is an error somewhere in the loop.
Can you post the code here for us to look at?

Cheers

alexh

2:50 pm on Dec 30, 2003 (gmt 0)

10+ Year Member



There is definately nothing wrong with the loop as I tested it printing the results to the screen rather than sending it via email. The offending function is $mail->setHtml($body, $altbody). Have a look:

$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++;
}

mogwai

4:41 pm on Dec 30, 2003 (gmt 0)

10+ Year Member



Hi,

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

alexh

5:01 pm on Dec 30, 2003 (gmt 0)

10+ Year Member



Your a genius, i put the command in the loop and it works. Thanks a lot for your help, I was starting to get to the end of my patience.