Skip to content

Instantly share code, notes, and snippets.

@thomasdegry
Created January 27, 2014 21:45
Show Gist options
  • Save thomasdegry/8658000 to your computer and use it in GitHub Desktop.
Save thomasdegry/8658000 to your computer and use it in GitHub Desktop.
$this->autoRender = false;
$content = $this->request->data['editor'];
$title = 'Newsletter R.T.S';
$name = 'R.T.S. Ieper';
$from_address = 'noreply@rts.be';
// $to = '';
// $subscribers = $this->Newsletter->find('all');
// foreach ($subscribers as $key => $subscriber) {
// $to .= $subscriber['Newsletter']['email'] . ',';
// // echo $subscriber['Newsletter']['email'] . '<br/>';
// }
// $to = rtrim($to, ',');
$to = 'degry.thomas@gmail.com, thomas.degry@student.howest.be, evegar1@live.com.mx';
$email = file_get_contents('http://' . $_SERVER['HTTP_HOST'] . $this->base . '/newsletter.html');
$email = str_replace('{{year}}', date('Y'), $email);
$email = str_replace('{{content}}', $content, $email);
$email = str_replace('{{title}}', $title, $email);
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=utf-8\r\n";
$headers .= "Content-Transfer-Encoding: 8bit\r\n";
$headers .= "X-Mailer: PHP/". phpversion();
$headers .= "From: =?UTF-8?B?". base64_encode($name) ."?= <$from_address>\r\n";
$headers .= 'BCC: '. $to . "\r\n";
mail(null, $title, $email, $headers);
echo 'done';
die();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment