You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
994 B

  1. <?php namespace Majestic\Mail;
  2. /**
  3. * @copyright NetMonsters <team@netmonsters.ru>
  4. * @link http://netmonsters.ru
  5. * @package Majestic
  6. * @subpackage mail
  7. * @since 2010-04-25
  8. */
  9. class Mailer
  10. {
  11. protected $headers;
  12. public function __construct($host)
  13. {
  14. $this->headers .= 'From: noreply@' . $host . "\r\n";
  15. $this->headers .= 'Date: '. date('r') ."\r\n";
  16. $this->headers .= "Return-Path: noreply@". $host ."\r\n";
  17. $this->headers .= "X-Priority: 3 (Normal)\r\n";
  18. $this->headers .= "Message-ID: <". md5(uniqid(time()))."@". $host .">\r\n";
  19. $this->headers .= "MIME-Version: 1.0\r\n";
  20. $this->headers .= "Content-Type: text/plain; charset=utf-8\r\n";
  21. $this->headers .= "Content-Transfer-Encoding: 16bit\r\n";
  22. }
  23. public function send($email, $subject, $message)
  24. {
  25. $subject = '=?UTF-8?B?' . base64_encode($subject) . "?=\r\n";
  26. return mail($email, $subject, $message, $this->headers);
  27. }
  28. }