使用php将电子邮件发送到多个地址

时间:2017-05-17 19:37:09

标签: php email-integration

它只会向第一个电子邮件地址发送电子邮件。第二个电子邮件地址不起作用,因为它是一个变量。你怎么看?

  $to = "email1@gmail.com,". $rs['email2'];
    $subject = "Hello";
    $from = "admin@itservice.com";
    $headers = "From: $from\r\n";
    $headers .= "MIME-Version: 1.0\r\n"
      ."Content-Type: multipart/mixed; boundary=\"1a2a3a\"";


    $message .= "This is a message..."
      ."--1a2a3a\r\n";

    $file = file_get_contents("memomemomemo4.pdf");



    // Send email

      $success = mail($to,$subject,$message,$headers);

2 个答案:

答案 0 :(得分:1)

为什么不:

$rs['email2'] = "me@me.com";
echo "email1@gmail.com,{$rs['email2']}";
# email1@gmail.com,me@me.com

答案 1 :(得分:-1)

请尝试使用以下语法:

$to = "email1@gmail.com,".$rs['email2'];