我正在做一个使用Codeigniter(移动网站)的项目。我希望用户收到的邮件,如注册,忘记密码,通讯等。目前我在做什么是这样的:邮寄服务
function sendEmail($email) {
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => '465',
'smtp_user' => '[email protected]',
'smtp_pass' => 'password',
'mailtype' => 'html',
'charset' => 'iso-8859-1'
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->from('[email protected]', 'user');
$this->email->to($email);
$this->email->subject('Thank You for Registering');
$this->email->message('Thank You for Registering .');
if($this->email->send()){
echo "Success";
}
else {
echo "failed";
}
}
这种运作良好。但是,当你想发送2-3种类型的邮件时,这是做事的正确方法吗?请帮助我。