mailer, some fixes, #16
git-svn-id: svn+ssh://code.netmonsters.ru/svn/majestic/branches/evo@142 4cb57b5f-5bbd-dd11-951b-001d605cbbc5
This commit is contained in:
@ -1,78 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Класс для отправки почты
|
||||
*
|
||||
* @copyright NetMonsters <team@netmonsters.ru>
|
||||
* @link http://netmonsters.ru
|
||||
* @package Core
|
||||
* @subpackage mail
|
||||
* @since
|
||||
* @version SVN: $Id$
|
||||
* @filesource $URL$
|
||||
*/
|
||||
|
||||
class Mailer
|
||||
{
|
||||
public $template_dir = 'mail';
|
||||
public $template = null;
|
||||
public $templater;
|
||||
public $headers;
|
||||
protected $host;
|
||||
|
||||
function __construct($host, $template = null)
|
||||
{
|
||||
if ($template !== null) {
|
||||
$this->templater = Load::templater(ACTION_TPL_PATH . '/' . $this->template_dir);
|
||||
$this->template = $template;
|
||||
}
|
||||
|
||||
$this->host = $host;
|
||||
|
||||
$this->headers .= 'From: robot@' . $this->host . "\r\n";
|
||||
$this->headers .= 'Date: '. date('r') ."\r\n";
|
||||
$this->headers .= "Return-Path: robot@". $this->host ."\r\n";
|
||||
$this->headers .= "X-Mailer: PHPMail Tool\r\n";
|
||||
$this->headers .= "Reply-To: robot@". $this->host ."\r\n";
|
||||
$this->headers .= "X-Priority: 3 (Normal)\r\n";
|
||||
$this->headers .= "Message-ID: <". md5(uniqid(time()))."@". $this->host .">\r\n";
|
||||
$this->headers .= "MIME-Version: 1.0\r\n";
|
||||
$this->headers .= "Content-Type: text/plain; charset=utf-8\r\n";
|
||||
$this->headers .= "Content-Transfer-Encoding: 16bit\r\n";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Отправляет письма
|
||||
*
|
||||
* @param mixed $mail
|
||||
* @param mixed $subject
|
||||
* @param mixed $data
|
||||
*/
|
||||
function send ($mail, $subject, $data)
|
||||
{
|
||||
$this->headers .= "To: ".$mail."\r\n";
|
||||
|
||||
foreach ($data as $key => $val) {
|
||||
$this->templater->assign($key, $val);
|
||||
}
|
||||
|
||||
$message = $this->templater->fetch($this->template.'.tpl');
|
||||
$encoded_subject = '=?UTF-8?B?' . base64_encode($subject) . "?=\r\n";
|
||||
return mail($mail, $subject, $message, $this->headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Отправка письма с непосредственным указанием контента
|
||||
*
|
||||
* @param string $email
|
||||
* @param string $subject
|
||||
* @param string $content
|
||||
* @return bool
|
||||
*/
|
||||
public function sendMessage($email, $subject, $content)
|
||||
{
|
||||
$encoded_subject = '=?UTF-8?B?' . base64_encode($subject) . "?=\r\n";
|
||||
return mail($email, $encoded_subject, $content, $this->headers);
|
||||
}
|
||||
}
|
||||
?>
|
Reference in New Issue
Block a user