我正在做一個使用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種類型的郵件時,這是做事的正確方法嗎?請幫助我。