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
|
class Mailer
|
||||||
{
|
{
|
||||||
public $template_dir = 'mail';
|
public $template_dir = 'mail';
|
||||||
public $template;
|
public $template = null;
|
||||||
public $templater;
|
public $templater;
|
||||||
public $headers;
|
public $headers;
|
||||||
protected $url;
|
protected $url;
|
||||||
|
|
||||||
function __construct($template)
|
function __construct($template = null)
|
||||||
{
|
{
|
||||||
$this->templater = Load::templater(ACTION_TPL_PATH.'/'.$this->template_dir);
|
if ($template !== null) {
|
||||||
$this->template = $template;
|
$this->templater = Load::templater(ACTION_TPL_PATH.'/'.$this->template_dir);
|
||||||
|
$this->template = $template;
|
||||||
|
}
|
||||||
|
|
||||||
$settings = Env::getParam('site_settings');
|
$settings = Env::getParam('site_settings');
|
||||||
$this->url = $settings['host_name'];
|
$this->url = $settings['host_name'];
|
||||||
|
|
||||||
/* если че забыл, не серчайте */
|
/* если че забыл, не серчайте */
|
||||||
$this->headers .= 'From: robot@' . $this->url . "\r\n";
|
$this->headers .= 'From: robot@' . $this->url . "\r\n";
|
||||||
$this->headers .= "Date: ".$this->RFCDate()."\r\n";
|
$this->headers .= 'Date: '. date('r') ."\r\n";
|
||||||
$this->headers .= "From: robot@". $this->url ."\r\n";
|
|
||||||
$this->headers .= "Return-Path: robot@". $this->url ."\r\n";
|
$this->headers .= "Return-Path: robot@". $this->url ."\r\n";
|
||||||
$this->headers .= "X-Mailer: PHPMail Tool\r\n";
|
$this->headers .= "X-Mailer: PHPMail Tool\r\n";
|
||||||
$this->headers .= "Reply-To: robot@". $this->url ."\r\n";
|
$this->headers .= "Reply-To: robot@". $this->url ."\r\n";
|
||||||
@ -62,21 +63,18 @@ class Mailer
|
|||||||
return mail($mail, $subject, $message, $this->headers);
|
return mail($mail, $subject, $message, $this->headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* возвращает дату
|
* Отправка письма с непосредственным указанием контента
|
||||||
*
|
*
|
||||||
*/
|
* @param string $email
|
||||||
function RFCDate() {
|
* @param string $subject
|
||||||
$tz = date("Z");
|
* @param string $content
|
||||||
$tzs = ($tz < 0) ? "-" : "+";
|
* @return bool
|
||||||
$tz = abs($tz);
|
*/
|
||||||
$tz = ($tz/3600)*100 + ($tz%3600)/60;
|
public function sendMessage($email, $subject, $content)
|
||||||
$result = sprintf("%s %s%04d", date("D, j M Y H:i:s"), $tzs, $tz);
|
{
|
||||||
|
$encoded_subject = '=?UTF-8?B?' . base64_encode($subject) . "?=\r\n";
|
||||||
return $result;
|
return mail($email, $encoded_subject, $content, $this->headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
@ -131,12 +131,24 @@ class User
|
|||||||
$model = new UserActivateModel();
|
$model = new UserActivateModel();
|
||||||
$link = 'http://' . $settings['host_name'] . '/activate/?key=' . $model->generateKey($login, $mail);
|
$link = 'http://' . $settings['host_name'] . '/activate/?key=' . $model->generateKey($login, $mail);
|
||||||
|
|
||||||
$mailer = new Mailer('UserRegister');
|
$text = new SettingsTextModel();
|
||||||
return $mailer->send($mail, 'Подтверждени E-mail ' . $settings['host_name'], array(
|
$message = $text->getText('mail_activate');
|
||||||
'link' => $link,
|
|
||||||
'site_name' => $settings['site_url'],
|
$replaces = array(
|
||||||
|
'link' => $link,
|
||||||
|
'host' => $settings['site_url'],
|
||||||
'email' => $mail,
|
'email' => $mail,
|
||||||
));
|
);
|
||||||
|
|
||||||
|
if (!$message) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($replaces as $key => $val) {
|
||||||
|
$message->text = str_replace('%' . $key . '%', $val, $message->text);
|
||||||
|
}
|
||||||
|
$mailer = new Mailer();
|
||||||
|
return $mailer->sendMessage($mail, 'Подтверждение E-mail ' . $settings['host_name'], $message->text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
Reference in New Issue
Block a user