Browse Source

email confirmation, #62

git-svn-id: svn+ssh://code.netmonsters.ru/svn/majestic/trunk@60 4cb57b5f-5bbd-dd11-951b-001d605cbbc5
master
pzinovkin 16 years ago
parent
commit
8be677b718
  1. 28
      classes/Mailer.class.php
  2. 5
      classes/User.class.php

28
classes/Mailer.class.php

@ -17,24 +17,28 @@ class Mailer
public $template;
public $templater;
public $headers;
protected $url;
function __construct($template)
{
$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@'.Env::Server('SERVER_NAME');
$this->headers .= 'From: robot@' . $this->url . "\r\n";
$this->headers .= "Date: ".$this->RFCDate()."\r\n";
$this->headers .= "From: robot@".Env::Server('SERVER_NAME')."\r\n";
$this->headers .= "Return-Path: robot@".Env::Server('SERVER_NAME')."\r\n";
$this->headers .= "From: robot@". $this->url ."\r\n";
$this->headers .= "Return-Path: robot@". $this->url ."\r\n";
$this->headers .= "X-Mailer: PHPMail Tool\r\n";
$this->headers .= "Reply-To: robot@".Env::Server('SERVER_NAME')."\r\n";
$this->headers .= "Reply-To: robot@". $this->url ."\r\n";
$this->headers .= "X-Priority: 3 (Normal)\r\n";
$this->headers .= "Message-ID: <". md5(uniqid(time()))."@".Env::Server('SERVER_NAME').">\r\n";
$this->headers .= "Message-ID: <". md5(uniqid(time()))."@". $this->url .">\r\n";
$this->headers .= "MIME-Version: 1.0\r\n";
$this->headers .= "Content-Type: text/plain; charset=windows-1251\r\n";
$this->headers .= "Content-Transfer-Encoding: 8bit\r\n";
$this->headers .= "Content-Type: text/plain; charset=utf-8\r\n";
$this->headers .= "Content-Transfer-Encoding: 16bit\r\n";
}
@ -54,15 +58,9 @@ class Mailer
$this->templater->assign($key, $val);
}
$message = $this->templater->fetch($this->template.'.tpl').'\r\n\r\nС любовью @робот.';
$message = $this->templater->fetch($this->template.'.tpl') . "\r\n\r\nС любовью @робот.";
/*
* как только заработает отправка писем на серваке,
* сразу надо раскоментить и проверить
*
* return mail($mail, $subject, $message, $this->headers);
*/
return true;
return mail($mail, $subject, $message, $this->headers);
}

5
classes/User.class.php

@ -127,11 +127,12 @@ class User
*/
static function sendActivateMail($mail, $login)
{
$settings = Env::getParam('site_settings');
$model = new UserActivateModel();
$link = 'http://'.Env::Server('SERVER_NAME').'/activate/?key=' . $model->generateKey($login, $mail);
$link = 'http://' . $settings['host_name'] . '/activate/?key=' . $model->generateKey($login, $mail);
$mailer = new Mailer('UserRegister');
return $mailer->send($mail, "Подтверждени E-mail ".Env::Server('SERVER_NAME'), array('link' => $link, 'site_name' => Env::Server('SERVER_NAME')));
return $mailer->send($mail, 'Подтверждени E-mail ' . $settings['host_name'], array('link' => $link, 'site_name' => $settings['site_url']));
}
}
Loading…
Cancel
Save