email sending changes
git-svn-id: svn+ssh://code.netmonsters.ru/svn/majestic/trunk@73 4cb57b5f-5bbd-dd11-951b-001d605cbbc5
This commit is contained in:
@ -14,23 +14,24 @@
|
||||
class Mailer
|
||||
{
|
||||
public $template_dir = 'mail';
|
||||
public $template;
|
||||
public $template = null;
|
||||
public $templater;
|
||||
public $headers;
|
||||
protected $url;
|
||||
|
||||
function __construct($template)
|
||||
function __construct($template = null)
|
||||
{
|
||||
$this->templater = Load::templater(ACTION_TPL_PATH.'/'.$this->template_dir);
|
||||
$this->template = $template;
|
||||
if ($template !== null) {
|
||||
$this->templater = Load::templater(ACTION_TPL_PATH.'/'.$this->template_dir);
|
||||
$this->template = $template;
|
||||
}
|
||||
|
||||
$settings = Env::getParam('site_settings');
|
||||
$this->url = $settings['host_name'];
|
||||
|
||||
/* если че забыл, не серчайте */
|
||||
$this->headers .= 'From: robot@' . $this->url . "\r\n";
|
||||
$this->headers .= "Date: ".$this->RFCDate()."\r\n";
|
||||
$this->headers .= "From: robot@". $this->url ."\r\n";
|
||||
$this->headers .= 'Date: '. date('r') ."\r\n";
|
||||
$this->headers .= "Return-Path: robot@". $this->url ."\r\n";
|
||||
$this->headers .= "X-Mailer: PHPMail Tool\r\n";
|
||||
$this->headers .= "Reply-To: robot@". $this->url ."\r\n";
|
||||
@ -62,21 +63,18 @@ class Mailer
|
||||
return mail($mail, $subject, $message, $this->headers);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* возвращает дату
|
||||
*
|
||||
*/
|
||||
function RFCDate() {
|
||||
$tz = date("Z");
|
||||
$tzs = ($tz < 0) ? "-" : "+";
|
||||
$tz = abs($tz);
|
||||
$tz = ($tz/3600)*100 + ($tz%3600)/60;
|
||||
$result = sprintf("%s %s%04d", date("D, j M Y H:i:s"), $tzs, $tz);
|
||||
|
||||
return $result;
|
||||
* Отправка письма с непосредственным указанием контента
|
||||
*
|
||||
* @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