This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* protected/config/main.php | |
-----------------------------------------------------------*/ | |
return array( | |
... | |
'components' => array( | |
'mailer' => array( | |
'class' => 'ext.mailer.EMailer', | |
'CharSet' => 'iso-2022-jp', | |
'Encoding' => '7bit', | |
), | |
... | |
/* protected/modules/user/UserModule.php | |
-----------------------------------------------------------*/ | |
class UserModule extends CWebModule | |
{ | |
... | |
/** | |
* メール送信 | |
* @param string $email メールアドレス | |
* @param string $subect 件名 | |
* @param string $view テンプレート名 | |
* @param array $vars テンプレートで使用する変数 | |
*/ | |
public static function sendMail($email, $subject, $view , $vars = array()) | |
{ | |
mb_language('Japanese'); | |
mb_internal_encoding(Yii::app()->charset); | |
$mailer =& Yii::app()->mailer; | |
$mailer->addAddress($email); | |
$mailer->From = Yii::app()->params['adminEmail']; | |
$mailer->FromName = mb_encode_mimeheader(Yii::app()->name); | |
$mailer->Subject = mb_encode_mimeheader($subject); | |
$mailer->getView($view, $vars); | |
$mailer->Body = mb_convert_encoding($mailer->Body, $mailer->CharSet); | |
$mailer->send(); | |
} | |
} | |
/* protected/modules/user/controllers/RegisterController.php | |
-----------------------------------------------------------*/ | |
class RegisterController extends Controller | |
{ | |
... | |
public function actionRegister() | |
{ | |
... | |
$subject = Yii::app()->name . 'からユーザ登録のお知らせ'; | |
UserModule::sendMail($model->email, $subject, 'register', array('activkey' => $model->activkey)); | |
... |
0 件のコメント:
コメントを投稿