我正在编写一个网站,这个网站有一个联系表格,但我对此有疑问。
代码返回了此错误。
'无法使用PHP SMTP发送电子邮件。您的服务器可能未配置为使用此方法发送邮件。'
以下代码:
$this->load->library('email');
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.gmail.com',
'smtp_port' => 587,
'smtp_user' => '', // change it to yours
'smtp_pass' => '', // change it to yours
'mailtype' => 'html',
'charset' => 'iso-8859-1',
'wordwrap' => TRUE
);
$this->email->initialize($config);
$dados = $this->input->post();
$this->email->from('', "Admin Team");
$this->email->to("test@domainname.com");
$this->email->subject("This is test subject line");
$this->email->message("Mail sent test message...");
$this->email->set_newline("\r\n");
if($this->email->send()){
$this->session->set_flashdata('success','Email enviado com sucesso!');
}else{
$this->session->set_flashdata('error',$this->email->print_debugger());
}
$this->load->view('includes/head.php');
$this->load->view('home/contato.php');
感谢您的帮助