Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 1st, 2012  |  syntax: None  |  size: 0.81 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. PHP Sending mass mails: One for each or one for all?
  2. require_once 'lib/swift_required.php';
  3.  
  4. //Create the Transport
  5. $transport = Swift_SmtpTransport::newInstance('localhost', 25);
  6.  
  7. //Create the Mailer using your created Transport
  8. $mailer = Swift_Mailer::newInstance($transport);
  9.  
  10. //Create a message
  11. $message = Swift_Message::newInstance('Wonderful Subject')
  12.   ->setFrom(array('john@doe.com' => 'John Doe'))
  13.   ->setTo(array('receiver@domain.org', 'other@domain.org' => 'A name'))
  14.   ->setBody('Here is the message itself')
  15.   ;
  16.  
  17. //Send the message
  18. $numSent = $mailer->batchSend($message);
  19.  
  20. printf("Sent %d messagesn", $numSent);
  21.  
  22. /* Note that often that only the boolean equivalent of the
  23.    return value is of concern (zero indicates FALSE)
  24.  
  25. if ($mailer->batchSend($message))
  26. {
  27.   echo "Sentn";
  28. }
  29. else
  30. {
  31.   echo "Failedn";
  32. }
  33.  
  34. */