简体   繁体   English

如何在Codeigniter中的localhost xampp上发送电子邮件?

[英]How to send email on localhost xampp in codeigniter?

I try to send email on localhost xampp using codeigniter. 我尝试使用codeigniter在localhost xampp上发送电子邮件。 I modified php.ini and sendemail.ini file in xampp follow the guide. 我按照指南修改了xampp中的php.ini和sendemail.ini文件。 my codeigniter code is follow. 我的codeigniter代码如下。

 public function send_mail() { $config['useragent'] = 'CodeIgniter'; $config['protocol'] = 'smtp'; $config['smtp_host'] = 'ssl://smtp.gmail.com'; $config['smtp_port'] = '587'; $config['smtp_user'] = '****@gmail.com'; $config['smtp_pass'] = '****'; $config['smtp_timeout'] = 5; $config['wordwrap'] = TRUE; $config['wrapchars'] = 76; $config['mailtype'] = 'html'; $config['charset'] = 'utf-8'; $config['validate'] = FALSE; $config['priority'] = 3; $config['crlf'] = "\\r\\n"; $config['newline'] = "\\r\\n"; $config['bcc_batch_mode'] = FALSE; $config['bcc_batch_size'] = 200; $this->load->library('email', $config); $from_email = "csharpdev0423@gmail.com"; $to_email = $this->input->post('email'); //Load email library $this->load->library('email'); $this->email->initialize($config); //$this->load->library('email', $config); $this->email->from($from_email, 'Identification'); $this->email->to($to_email); $this->email->subject('Send Email Codeigniter'); $this->email->message('The email send using codeigniter library'); //Send mail if($this->email->send()) $this->session->set_flashdata("email_sent","Congragulation Email Send Successfully."); else $this->session->set_flashdata("email_sent","You have encountered an error"); $this->load->view('contact_email_form'); } 
But it have above error. 但是它有上面的错误。

A PHP Error was encountered Severity: Warning 遇到PHP错误严重性:警告

Message: fsockopen(): SSL operation failed with code 1. OpenSSL Error messages: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol 消息:fsockopen():SSL操作失败,代码为1。OpenSSL错误消息:error:140770FC:SSL例程:SSL23_GET_SERVER_HELLO:未知协议

Filename: libraries/Email.php 文件名:libraries / Email.php

Line Number: 2055 行号:2055

You can changes following email config array. 您可以更改以下电子邮件配置数组。

<?php 
// change hostname
$config['smtp_host'] = 'smtp.gmail.com';

// change stmp port number
$config['smtp_port'] = '465';

// add smtp_crypto
$config['smtp_crypto'] = 'ssl';


// Change charset
$config['charset'] = 'iso-8859-1';

?>

Hope it will help. 希望它会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM