Guest User

Untitled

a guest
Jul 2nd, 2018
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.80 KB | None | 0 0
  1. <?php
  2. function send($message, $to) {
  3.     require_once "Mail.php";
  4.     $from = "Info <info@example.com>";
  5.     $subject = "Newsletter";
  6.     $host = "****";
  7.     $username = "****";
  8.     $password = "****";
  9.     $headers = array (
  10.         'From' => $from,
  11.         'To' => $to,
  12.         'Subject' => $subject,
  13.         'Content-Type' => 'text/html; charset="utf-8"'
  14.     );
  15.     $smtp = Mail::factory('smtp',
  16.         array (
  17.             'host' => $host,
  18.             'auth' => true,
  19.             'username' => $username,
  20.             'password' => $password
  21.         )
  22.     );
  23.     $smtp->send($to, $headers, $message);
  24. }
  25.  
  26.  
  27. foreach (DB:getEmails() as $email) {
  28.     $messageData->user = $email;
  29.     // In `letter.php` instead of using `^user^`, use `<?= $messageData->user ?>`.  You'll have more    flexibility
  30.     $message = $foo = include 'messages/letter.php';
  31.     send(str_replace('^user^',$email,$message),$email);
  32. }
  33. ?>
Add Comment
Please, Sign In to add comment