【发布时间】:2015-11-10 09:45:20
【问题描述】:
您好,我需要帮助,我一直在尽力发送 html 电子邮件,但它不起作用,我只是收到电子邮件尚未发送的警报。 在库 > email.php 文件中,我没有更改任何内容,只是保留为默认值,请帮助,因为两周前我一直在尝试解决这个问题,请帮助!
$name = $this->input->post('name');
$email = $this->input->post('email');
$comment = $this->input->post('message');
$config['mailtype'] = 'html';
$this->load->library('email',$config);
$message = "<html>";
$message .= "<style type='text/css'> body,td,th { font-family: Arial, Helvetica, sans-serif; font-size: 13px;}</style>";
$message .= "<body>";
$message .= "<table width='650' border='1' cellspacing='0' cellpadding='6'> ";
$message .= "<tr>";
$message .= "<td colspan='2' bgcolor='#6495ed' style='font-weight: bold;'>CONTACT DETAILS</td>";
$message .= "</tr>";
$message .= "<tr>";
$message .= "<td width='237'>Client Name:</td>"."<td width='393'>".$name."</td>";
$message .= "</tr>";
$message .= "<tr>";
$message .= "<td>Message:</td>"."<td>".$comment."</td>";
$message .= "</table><br><br>";
$message .= "</body>";
$message .= "</html>";
$this->email->from($email,$name);
$this->email->to('fredma@gmail.com','nfy@layeaketz.com');
$this->email->subject('New Contact Email from Client');
$this->email->message($message);
$this->email->send();
if($this->email->send()== TRUE){
echo'message sent';
}else{
echo'message not sent';
}
【问题讨论】:
-
我只看到这个
$config['mailtype'] = 'html';你有用户指南中显示的 smtp 主机等吗? codeigniter.com/user_guide/libraries/… -
添加此
$config['charset'] = 'utf'; $config['wordwrap'] = 'TRUE';后检查 -
谢谢让我编辑然后给你反馈
-
您收到这封邮件了吗?
-
谢谢,但我得到了这个错误............无法在“localhost”端口 25 连接到邮件服务器,请验证 php.ini 中的“SMTP”和“smtp_port”设置或使用 ini_set()
标签: php codeigniter email