public function init()
{
$this->_mailer = new \PHPMailer();
switch ($this->method) {
case 'smtp':
$this->_mailer->isSMTP();
$this->_mailer->Host = $this->smtp['host'];
if (!empty($this->smtp['username'])) {
$this->_mailer->SMTPAuth = true;
$this->_mailer->Username = $this->smtp['username'];
$this->_mailer->Password = $this->smtp['password'];
} else {
$this->_mailer->SMTPAuth = false;
}
if (isset($this->smtp['port'])) {
$this->_mailer->Port = $this->smtp['port'];
}
if (isset($this->smtp['secure'])) {
$this->_mailer->SMTPSecure = $this->smtp['secure'];
}
if (isset($this->smtp['debug'])) {
$this->_mailer->SMTPDebug = (int) $this->smtp['debug'];
}
break;
case 'sendmail':
$this->_mailer->isSendmail();
break;
default:
$this->_mailer->isMail();
}
$this->_mailer->CharSet = \Yii::app()->charset;
parent::init();
}