From 8be677b718cde77378efa4f390fdcc0fae3347f9 Mon Sep 17 00:00:00 2001 From: pzinovkin Date: Thu, 5 Feb 2009 14:57:42 +0000 Subject: [PATCH] email confirmation, #62 git-svn-id: svn+ssh://code.netmonsters.ru/svn/majestic/trunk@60 4cb57b5f-5bbd-dd11-951b-001d605cbbc5 --- classes/Mailer.class.php | 28 +++++++++++++--------------- classes/User.class.php | 5 +++-- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/classes/Mailer.class.php b/classes/Mailer.class.php index 802b28b..269f49f 100644 --- a/classes/Mailer.class.php +++ b/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); } diff --git a/classes/User.class.php b/classes/User.class.php index 168f11e..90db477 100644 --- a/classes/User.class.php +++ b/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'])); } }