I want to send two emails at a same time for two different users. I am using php mail function. below is the code.
Send_Mail('abc@example.com,abc2@example.com','Welcome',$message);
when I send it to single user, it works fine.But when I add two mail address it didnt work.. Is there any other method is there to solve this??? Help me frnds..
Thanks in Advance..
You may need to specify the recipients in the header if you send the email to more than one address.
$to = 'abc@example.com' . ', ' . 'abc2@example.com';
$subject = 'Welcome';
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "
";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "
";
// Additional headers
$headers .= 'To: ' . $to . "
";
//$headers .= 'From: Someone <someone@example.com>' . "
";
//$headers .= 'Cc: otherperson@example.com' . "
";
//$headers .= 'Bcc: theotherperson@example.com' . "
";
Send_Mail($to, $subject, $message, $headers);
$emailArray = array ('abc@example.com','abc2@example.com');
for($i=0;$i<count($emailArray);$i++)
{
Send_Mail($emailArray[$i],'Welcome',$message);
}
Now you can send unlimited emails...based on the array data
the mail function works absolutely fine with multiple ids, check out the smtp logs while sending the mail. may be something else is breaking.
for more reference: http://php.net/manual/en/function.mail.php
Try this:
$recipients = array('abc@example.com','abc2@example.com');
foreach ($recipients as $to) {
Send_Mail($to,'Welcome',$message);
}
OR
$to = 'abc@example.com,abc2@example.com';
Send_Mail($to,'Welcome',$message);
Try this:
// multiple recipients
$to = 'abc@example.com' . ', '; // note the comma
$to .= 'def@example.com';
send_Mail($to, 'Welcome', $message);