How to use phpgmailer class for sending mails to multiple id’s at a time (in cc or to addresses)
Hi Folks,
In my previous post i had presented you hoe send mails using phpgmailer which help us sending mails from our locahost itself.
With that mailer funtion we met with problem, due to which we were unable to send mails to multiple accounts …
In general we use to send mails to multiple accounts by specifying to addresses with a “,” separated as below :
$to=”mail_id1@domainname.com,mail_id2@domainname.com,mail_id3@domainname.com”;
Which was wrong while using the Phpgmailer class, for this we need to split those mail id’s individually and add those to Phpgmailer class as follows :
$to_arr=explode(”,”,$to);
$count=sizeof($to_arr);
for($i=0;$i<$count;$i++){
$mail->AddAddress($to_arr[$i]); } now you can send those mails to multiple ids at a time by using the procedure in our previous post.
Note : for adding multiple ids in CC also use the same procedure as abov. like
$cc_arr=explode(”,”,$cc);
$count=sizeof($cc_arr);
for($i=0;$i<$count;$i++){
$mail->AddCC($cc_arr[$i]);
}
For more supporting funtions just have look at :phpmailer\class.phpgmailer.php file which would be availble with following link :
http://www.vulgarisoip.com/files/phpgmailer.zip

