skypanther
Exalted Code Master!
PHPMailer uses a mix of object properties and methods for setting required values. So, while you can do $mail->From = '[email protected]' you can't do that with the To addresses. It's a bit confusing.
Maybe this will help? Here's a simplified version of a function I use to send mail. I set various values in a config file (such as the mail server, whether to use SMTP auth, and so forth). My config file also loads the phpmailer class.
You can add an array to the TO line or a single address. The function supports that. You could add these to the CC or BCC lines instead if you wanted.
@zardiw - on one of my client sites, they have close to a thousand addresses on their list. My code loops through batches of 50 at a time, creating an individual email for each recipient putting them on the To line. I pause a few seconds between each batch. This is basically what newsletter systems like phpList do.
Make sure you've sent in the JodoHost bulk mailing form to the legal department so you don't have all mail blocked on your domain.
Tim
Maybe this will help? Here's a simplified version of a function I use to send mail. I set various values in a config file (such as the mail server, whether to use SMTP auth, and so forth). My config file also loads the phpmailer class.
Code:
function sendEmail($to, $subject, $message) {
global $config;
// email address is good, process message
$mail = new PHPMailer();
$mail->IsSMTP(); // telling the class to use SMTP
$mail->SMTPAuth = $config['SMTP_AUTH']; // telling the class to use SMTP Auth
$mail->Username = $config['SMTP_USER'];
$mail->Password = $config['SMTP_USER_PASSWORD'];
$mail->Host = $config['SMTP_SERVER'];
$mail->From = $config['FROM_ADDRESS']; // '[email protected]'
$mail->FromName = $config['FROM_NAME']; // 'Sally Sample'
if(strpos($to, ',')!==FALSE) {
// If passed a comma-separated list of email addresses
// turn the list into an array and add them to the TO line
$toArray = explode(',',$to);
$cnt=count($toArray);
for($i=0;$i<$cnt;$i++) {
// add an array of email addresses to the TO line
$mail->AddAddress($toArray[$i]);
} // end for()
} else {
// passed a single address, add it as the to list
$mail->AddAddress($to);
} // end if(strpos...
$mail->Subject = $subject;
$mail->Body = $message;
$mail->WordWrap = 70;
if(!$mail->Send()) {
return $mail->ErrorInfo;
}
}
You can add an array to the TO line or a single address. The function supports that. You could add these to the CC or BCC lines instead if you wanted.
@zardiw - on one of my client sites, they have close to a thousand addresses on their list. My code loops through batches of 50 at a time, creating an individual email for each recipient putting them on the To line. I pause a few seconds between each batch. This is basically what newsletter systems like phpList do.
Make sure you've sent in the JodoHost bulk mailing form to the legal department so you don't have all mail blocked on your domain.
Tim