我有一些问题,这意味着我没有收到来自表单的邮件...
代码如下所示:
public function send_email(){
$this->load->library("form_validation");
$this->form_validation->set_rules("fullName", "Full Name", "required|alpha|xss_clean");
$this->form_validation->set_rules("email", "Email Address", "required|valid_email|xss_clean");
$this->form_validation->set_rules("message", "Message", "required|xss_clean");
if($this->form_validation->run() == FALSE){
$data["message"] = "";
$this->load->view("site_header");
$this->load->view("site_nav");
$this->load->view("content_comment", $data);
$this->load->view("site_footer");
}else{
$data["message"] = "The email was successfully been sent!";
$this->load->library("email");
$this->email->from(set_value("email"), set_value("fullName"));
$this->email->to("paulharbuz@gmail.com");
$this->email->subject("Message from our form");
$this->email->message(set_value("message"));
$this->email->send();
echo $this->email->print_debugger();
$this->load->view("site_header");
$this->load->view("site_nav");
$this->load->view("content_comment", $data);
$this->load->view("site_footer");
}
}
我得到一个看起来像这样的错误:
无法使用 PHP mail() 发送电子邮件。您的服务器可能未配置为使用此方法发送邮件。**
这是来自我的 php.ini 文件吗?
我已经在http://php.net/manual/en/ref.mail.php上设置了我的文件阅读这部分
我找到了解决方案:在 config: email.php 中创建一个看起来像这样的文件
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
| -------------------------------------------------------------------
| EMAIL CONFING
| -------------------------------------------------------------------
| Configuration of outgoing mail server.
| */
$config['wordwrap'] = FALSE;
$config['mailtype'] = 'html';
$config['crlf'] = '\r\n';
$config['charset']='utf-8';
$config['newline']="\r\n";
$config['priority']=1;
$config['protocol']='smtp';
$config['smtp_host']='ssl://smtp.googlemail.com';
$config['smtp_port']='465';
$config['smtp_timeout']='30';
$config['smtp_user']='gcc.sandbox@gmail.com';
$config['smtp_pass']='qwaszx12';
$config['newline']="\r\n";
/* End of file email.php */
/* Location: ./system/application/config/email.php */
然后将其加载到您的主控制器中,例如:$this->email->initialize($this->config->config);
就是这样!