Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function send($message, $to) {
- require_once "Mail.php";
- $from = "Info <info@example.com>";
- $subject = "Newsletter";
- $host = "****";
- $username = "****";
- $password = "****";
- $headers = array (
- 'From' => $from,
- 'To' => $to,
- 'Subject' => $subject,
- 'Content-Type' => 'text/html; charset="utf-8"'
- );
- $smtp = Mail::factory('smtp',
- array (
- 'host' => $host,
- 'auth' => true,
- 'username' => $username,
- 'password' => $password
- )
- );
- $smtp->send($to, $headers, $message);
- }
- foreach (DB:getEmails() as $email) {
- $messageData->user = $email;
- // In `letter.php` instead of using `^user^`, use `<?= $messageData->user ?>`. You'll have more flexibility
- $message = $foo = include 'messages/letter.php';
- send(str_replace('^user^',$email,$message),$email);
- }
- ?>
Add Comment
Please, Sign In to add comment