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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -131,12 +131,24 @@ class User
|
||||
$model = new UserActivateModel();
|
||||
$link = 'http://' . $settings['host_name'] . '/activate/?key=' . $model->generateKey($login, $mail);
|
||||
|
||||
$mailer = new Mailer('UserRegister');
|
||||
return $mailer->send($mail, 'Подтверждени E-mail ' . $settings['host_name'], array(
|
||||
'link' => $link,
|
||||
'site_name' => $settings['site_url'],
|
||||
$text = new SettingsTextModel();
|
||||
$message = $text->getText('mail_activate');
|
||||
|
||||
$replaces = array(
|
||||
'link' => $link,
|
||||
'host' => $settings['site_url'],
|
||||
'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