我看过很多与此问题相关的帖子,我已经完成了给出的说明,但总是遇到相同的错误..
我想使用 Code Igniter 2.1.3 发送 smtp gmail,这是代码:
class Email extends CI_Controller{
function index(){
$config = Array(
'protocol' => 'smtp',
'smtp_crypto' => 'ssl',
'smtp_host' => 'smtp.gmail.com',
'smtp_user' => '[email protected]',
'smtp_pass' => '***********',
'smtp_port' => 25,
'mailtype' => 'text',
'smtp_timeout' => 15,
'charset' => 'iso-8859-1'
);
$this->load->library('email', $config);
$this->email->set_crlf("\r\n");
$this->email->set_newline("\r\n");
$this->email->from("[email protected]", "myName");
$this->email->to("[email protected]");
$this->email->subject("Email Test");
$this->email->message("This is email test");
if($this->email->send()){
echo 'Email Send';
} else{
show_error($this->email->print_debugger());
}
}
并且错误总是这样,
Message: fsockopen(): unable to connect to ssl://smtp.gmail.com:25 (A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. )
请帮我修复这个错误,谢谢:)
您需要在服务器配置中的 php.ini 文件中启用 ssl,如果您使用的是 Xampp 服务器,则可以检查它是否已启用。在其中转到 PHP 信息搜索 ssl.........
您需要删除;在 php.ini 文件中的 extension=php_openssl.dll 这行之前。
您需要启用 OpenSSL......
我最近遇到了这个错误。您的代码中有一个小错误......
function sendMail()
{
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => '[email protected]', // change it to yours
'smtp_pass' => 'xxx', // change it to yours
'mailtype' => 'html',
'charset' => 'iso-8859-1',
'wordwrap' => TRUE
);
$message = $this->load->view('upload_success','',TRUE);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->from('[email protected]'); // change it to yours
$this->email->to('[email protected]');// change it to yours
$this->email->subject('Resume from JobsBuddy for your Job posting');
$this->email->message($message);
if($this->email->send())
{
echo 'Email sent.';
}
else
{
show_error($this->email->print_debugger());
}
}
这是我在解决您面临的问题后使用的工作代码......
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)