我正在使用Codeigniter预订应用程序。我被困在从本地主机发送的电子邮件中。我正在使用gmail smtp发送电子邮件。我正在使用email / booking_email.php视图文件作为电子邮件模板。但是,当我在本地主机上运行包含电子邮件发送脚本的网站页面时,它会继续加载,但不会发送电子邮件。
$email = "[email protected]";
$name = "Wiyo HK";
$email_config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.gmail.com',
'smtp_port' => 465,
'smtp_user' => '[email protected]',
'smtp_pass' => '********',
'mailtype' => 'html',
'charset' => 'iso-8859-1'
);
$this->load->library('email', $email_config);
$this->email->from($email, $name);
$this->email->to($this->bookings_class->get_email());
$this->email->reply_to($email, $name);
$subject = 'This is Booking email from Wiyo HK';
$this->email->subject($subject);
$data = array('customer_name' => 'Avash Poudel');
$message = $this->load->view('email/booking_email', $data, TRUE);
$this->email->message($message);
echo $result = $this->email->send();
除非进行配置,否则Localhost不支持直接发送电子邮件。在本地主机中,它不能像这样工作。为了进行测试,请mail()
在本地主机和smtp
服务器上使用协议。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句