【问题标题】:Error sending mail with codeigniter on wamp server在 wamp 服务器上使用 codeigniter 发送邮件时出错
【发布时间】:2017-11-18 02:12:18
【问题描述】:

我正在使用带有最新版本 CodeIgniter 的 wamp 服务器。我从我的 php.ini 中取消了 extension=php_openssl.dll 的注释。我没有安装 AVG 杀毒软件。然而它不起作用。我在我的 autoload.php 中自动加载了电子邮件库

我的邮件发件人控制器:

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Testmail extends CI_Controller {

public function index()
{ 
    //configure email settings
    $config['protocol'] = 'sendmail';
    $config['smtp_host'] = 'ssl://smtp.gmail.com'; //smtp host name
    $config['smtp_port'] = '465'; //smtp port number
    $config['smtp_user'] = 'my_email@gmail.com';
    $config['smtp_pass'] = 'correct_password'; //$from_email password
    $config['mailtype'] = 'html';
    $config['charset'] = 'iso-8859-1';
    $config['wordwrap'] = TRUE;
    $config['newline'] = "\r\n"; //use double quotes
    $this->email->initialize($config);

    //send mail
    $this->email->from('nosisky@gmail.com', 'Mydomain');
    $this->email->to('nosisky@gmail.com');
    $this->email->subject('testing mail');
    $this->email->message('testing mail server class');
    $this->email->send();
    echo $this->email->print_debugger(); 
}


}

这是我打印 CodeIgniter 电子邮件调试器时收到的错误消息的一部分。

A PHP Error was encountered

Severity: Warning

Message: fsockopen(): SSL operation failed with code 1. OpenSSL Error 
messages: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown 
protocol

Filename: libraries/Email.php

Line Number: 2063

【问题讨论】:

标签: php codeigniter email


【解决方案1】:

我使用了下面的代码。它工作正常。将协议更改为 smtp。还可以尝试在您的代码中删除或包含 ssl://

$config = array(
        'protocol' => 'smtp',
        'smtp_host' => 'ssl://just127.justhost.com',
        'smtp_port' => 465,
        'smtp_user' => 'user@gmail.com',
        'smtp_pass' => 'yourpassword',
        'mailtype' => 'html',
        'charset' => 'iso-8859-1'
);

【讨论】:

  • 完成此操作后,我从电子邮件调试器中获得了421 server busy too many connections
猜你喜欢
  • 2018-06-18
  • 1970-01-01
  • 1970-01-01
  • 2016-08-06
  • 2016-01-02
  • 2013-11-21
  • 2015-01-06
  • 1970-01-01
  • 2019-02-15
相关资源
最近更新 更多