Reputation: 1816
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('[email protected],[email protected]','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..
Upvotes: 0
Views: 444
Reputation: 121
Try this:
// multiple recipients
$to = '[email protected]' . ', '; // note the comma
$to .= '[email protected]';
send_Mail($to, 'Welcome', $message);
Upvotes: 1
Reputation: 404
You may need to specify the recipients in the header if you send the email to more than one address.
$to = '[email protected]' . ', ' . '[email protected]';
$subject = 'Welcome';
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= 'To: ' . $to . "\r\n";
//$headers .= 'From: Someone <[email protected]>' . "\r\n";
//$headers .= 'Cc: [email protected]' . "\r\n";
//$headers .= 'Bcc: [email protected]' . "\r\n";
Send_Mail($to, $subject, $message, $headers);
Upvotes: 0
Reputation: 6000
Try this:
$recipients = array('[email protected]','[email protected]');
foreach ($recipients as $to) {
Send_Mail($to,'Welcome',$message);
}
OR
$to = '[email protected],[email protected]';
Send_Mail($to,'Welcome',$message);
Upvotes: 2
Reputation: 1446
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
Upvotes: 1
Reputation: 2051
$emailArray = array ('[email protected]','[email protected]');
for($i=0;$i<count($emailArray);$i++)
{
Send_Mail($emailArray[$i],'Welcome',$message);
}
Now you can send unlimited emails...based on the array data
Upvotes: 1