$emailContent = "<h2>Test Mail</h2>";
$getData = array();
$getData['email'] = 'test@gmail.com';
$email_config = Array(
'mailtype' => 'html',
'protocol' => 'smtp',
'smtp_host' => 'tls://test.amazonaws.com',
'smtp_port' => 465,
'smtp_user' => '********',
'smtp_pass' => '*********',
'charset' => 'iso-8859-1'
);
$this->load->library('email', $email_config);
$this->email->to($data['to']);
if (isset($data['from']) && !empty($data['from'])) {
$this->email->from($data['from']);
}
if (isset($data['bcc']) && !empty($data['bcc'])) {
$this->email->bcc($data['bcc']);
}
if (isset($data['cc']) && !empty($data['cc'])) {
$this->email->cc($data['cc']);
}
$this->email->subject($subject);
$this->email->message($emailContent);
if (isset($data['attachment']) && !empty($data['attachment']))
{
$this->email->attach($data['attachment']);
}
$this->email->set_newline("\r\n");
if ($this->email->send()) {
echo "success";
} else {
echo $this->email->print_debugger();
exit;
}
邮件包含html标签。 使用上面的代码发送邮件,邮件将使用html标签。