Batch Send Email with SwiftMailer

后端 未结 1 1025
情深已故
情深已故 2021-02-06 11:11

I\'m currently using SwiftMailer to send out emails to several users (up to 50). I have it set up and working properly, however, I\'m not quite sure how to pull the recipients

1条回答
  •  醉话见心
    2021-02-06 11:48

    I am not quite sure that I got your question right, but here is a way of doing it:

    setSubject('Let\'s get together today.')
      ->setFrom(array('myfrom@domain.com' => 'From Me'))
      ->setBody('Here is the message itself')
      ->addPart('Test message being sent!!', 'text/html')
    ;
    
    $data = mysql_query('SELECT first, last, email FROM users WHERE is_active=1') or die(mysql_error());
    while($row = mysql_fetch_assoc($data))
    {
       $message->addTo($row['email'], $row['first'] . ' ' . $row['last']);
    }
    
    $message->batchSend();
    ?>
    

    I hope that's what you wanted.

    0 讨论(0)
提交回复
热议问题