kigoobe
07-10-2006, 10:21 AM
Hi guys,
well, swift mail is having a script that works like this: $subject = 'Some subject';
$sender = '"George Bush" <george@bush.com>';
$recipients = array();
$result = mysql_query("SELECT name, surname, email from $my_table");
while ($row = mysql_fetch_assoc($result)) {
$recipients[] = array($row['name'].' '.$row['surname'], $row['email']);
}
$message = stripslashes($_POST['themessage']);
if ($mailer->isConnected())
{
$mailer->send(
$recipients,
$sender,
$subject,
$message
);
$mailer->close();
}
This works fine. Now I wanted to add something like Hi .$row[name] at the beginning of every mail send. So, I have tried to modify this script in this way, $subject = 'Some subject';
$sender = '"George Bush" <george@bush.com>';
$recipients = array();
$thename = array();
$result = mysql_query("SELECT name, surname, email from $my_table");
while ($row = mysql_fetch_assoc($result)) {
$recipients[] = array($row['name'].' '.$row['surname'], $row['email']);
$thename[] = array($row['name']);
$message = '<p>Hi '.$thename.'</p>';
}
$message .= stripslashes($_POST['themessage']);
if ($mailer->isConnected())
{
$mailer->send(
$recipients,
$sender,
$subject,
$message
);
$mailer->close();
} Unfortunately, when the email is going, senders are getting this: Hi Array
Message goes here ...
Can anyone help me to figure out where I'm doing something wrong?
Thanks a lot.
PS. I think I am not even sure if it's possible. Swiftmailer is sending the mail once only for all the addresses, taking all the addresses in an array. Had it been sending seperate mail to each, this could have been possible, as in mail(). I still would like to see what other's think, and may be Swiftmailer is not the best solution to send mass mail in that case (and in this way).
well, swift mail is having a script that works like this: $subject = 'Some subject';
$sender = '"George Bush" <george@bush.com>';
$recipients = array();
$result = mysql_query("SELECT name, surname, email from $my_table");
while ($row = mysql_fetch_assoc($result)) {
$recipients[] = array($row['name'].' '.$row['surname'], $row['email']);
}
$message = stripslashes($_POST['themessage']);
if ($mailer->isConnected())
{
$mailer->send(
$recipients,
$sender,
$subject,
$message
);
$mailer->close();
}
This works fine. Now I wanted to add something like Hi .$row[name] at the beginning of every mail send. So, I have tried to modify this script in this way, $subject = 'Some subject';
$sender = '"George Bush" <george@bush.com>';
$recipients = array();
$thename = array();
$result = mysql_query("SELECT name, surname, email from $my_table");
while ($row = mysql_fetch_assoc($result)) {
$recipients[] = array($row['name'].' '.$row['surname'], $row['email']);
$thename[] = array($row['name']);
$message = '<p>Hi '.$thename.'</p>';
}
$message .= stripslashes($_POST['themessage']);
if ($mailer->isConnected())
{
$mailer->send(
$recipients,
$sender,
$subject,
$message
);
$mailer->close();
} Unfortunately, when the email is going, senders are getting this: Hi Array
Message goes here ...
Can anyone help me to figure out where I'm doing something wrong?
Thanks a lot.
PS. I think I am not even sure if it's possible. Swiftmailer is sending the mail once only for all the addresses, taking all the addresses in an array. Had it been sending seperate mail to each, this could have been possible, as in mail(). I still would like to see what other's think, and may be Swiftmailer is not the best solution to send mass mail in that case (and in this way).