我想为两个不同的用户同时发送两封电子邮件。我正在使用php邮件功能。下面是代码。
Send_Mail('abc@example.com,abc2@example.com','Welcome',$message);
当我发送给单个用户时,它工作正常。但是当我添加两个邮件地址时,它没有工作.. 有没有其他方法可以解决这个问题?帮帮我..
先谢谢..
答案 0 :(得分:2)
试试这个:
$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);
答案 1 :(得分:1)
$emailArray = array ('abc@example.com','abc2@example.com');
for($i=0;$i<count($emailArray);$i++)
{
Send_Mail($emailArray[$i],'Welcome',$message);
}
现在您可以根据数组数据发送无限量的电子邮件
答案 2 :(得分:1)
使用多个ID,邮件功能可以正常工作,在发送邮件时查看smtp日志。可能是其他东西正在破裂。
答案 3 :(得分:1)
试试这个:
//多个收件人
$ to ='abc@example.com'。 ','; //记下逗号
$ to。='def@example.com';
send_Mail($ to,'Welcome',$ message);
答案 4 :(得分:0)
如果您将电子邮件发送到多个地址,则可能需要在标题中指定收件人。
$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' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= 'To: ' . $to . "\r\n";
//$headers .= 'From: Someone <someone@example.com>' . "\r\n";
//$headers .= 'Cc: otherperson@example.com' . "\r\n";
//$headers .= 'Bcc: theotherperson@example.com' . "\r\n";
Send_Mail($to, $subject, $message, $headers);