【发布时间】:2018-06-18 00:21:20
【问题描述】:
我正在尝试使用 WAMP localhost 将电子邮件从我的 gmail id 发送到 codeigniter 的另一个电子邮件 id。
我收到以下错误
你好:F
遇到以下 SMTP 错误:F
无法使用 PHP SMTP 发送电子邮件。
您的服务器可能未配置为使用此方法发送邮件。
这是我的控制器功能中的电子邮件发送代码
$config['useragent'] = 'CodeIgniter';
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'smtp.gmail.com';
$config['smtp_user'] = 'myemail@gmail.com'; // Your gmail id
$config['smtp_pass'] = '****'; // Your gmail Password
$config['smtp_port'] = 465;
// $config['mailpath'] = 'D:\wamp64\sendmail';
// $config['smtp_timeout']='30';
$config['wordwrap'] = TRUE;
$config['wrapchars'] = 76;
$config['mailtype'] = 'html';
$config['charset'] = 'iso-8859-1';
$config['validate'] = FALSE;
$config['priority'] = 3;
$config['newline'] = "\r\n";
$config['crlf'] = "\r\n";
// $config['smtp_crypto'] = 'ssl';
$this->load->library('email');
$this->email->initialize($config);
$this->email->from('myemail@gmail.com', 'Sana Riaz');
$this->email->to('myemail@gmail.com');
$this->email->subject('Email Test');
$this->email->message('Testing the email class.');
//$this->email->send();
if($this->email->send()){
echo "sent";
}else
show_error($this->email->print_debugger());
这些是我在 php.ini 文件中所做的设置,这些设置在旧帖子中有所建议。
extension=php_openssl.dll
[curl]
; A default value for the CURLOPT_CAINFO option. This is required to be an
; absolute path.
curl.cainfo ="D:\wamp64\bin\mariadb\mariadb10.2.8\mysql-test\std_data\cacert.pem"
[openssl]
; The location of a Certificate Authority (CA) file on the local filesystem
; to use when verifying the identity of SSL/TLS peers. Most users should
; not specify a value for this directive as PHP will attempt to use the
; OS-managed cert stores in its absence. If specified, this value may still
; be overridden on a per-stream basis via the "cafile" SSL stream context
; option.
openssl.cafile="D:\wamp64\bin\mariadb\mariadb10.2.8\mysql-test\std_data\cacert.pem"
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = smtp.gmail.com
; http://php.net/smtp-port
smtp_port = 465
; For Win32 only.
; http://php.net/sendmail-from
sendmail_from ="myemail@gmail.com"
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
sendmail_path ="D:\wamp64\sendmail\sendmail.exe -t"
这些是我尝试过的其他东西也没有用
-
使用 sendmail 和 mail 而不是
$config['protocol'] = 'smtp';分别产生以下错误(邮件)
无法使用 PHP mail() 发送电子邮件。您的服务器可能不是 配置为使用此方法发送邮件。
(发送邮件)
退出状态码:1 无法打开到 Sendmail 的套接字。请检查 设置。无法使用 PHP Sendmail 发送电子邮件。您的服务器可能 未配置为使用此方法发送邮件。
-
将端口 465 更改为 25 和 587 会产生以下错误
220 smtp.gmail.com ESMTP v78sm12109697wmv.27 - gsmtp
-
添加
$config['smtp_crypto'] = 'ssl';会产生以下错误fsockopen():SSL 操作失败,代码为 1。OpenSSL 错误消息: 错误:140770FC:SSL 例程:SSL23_GET_SERVER_HELLO:未知协议
禁用防火墙、杀毒软件等
从 Gmail 帐户启用
IMAP和POP
我不知道我做错了什么或我错过了什么。任何建议都会非常有帮助
这些是我之前遇到并尝试过但没有成功的一些帖子
【问题讨论】:
-
请您详细说明您的问题:
send email from my gmail account to another gmail account from codeignitor。这对我来说还不清楚...... -
实际上我想从我的 gmail id 发送电子邮件到 codeignitor 的另一个 gmail id。
-
当您首先使用加密端口号 (465) 时,我会尝试取消注释此行
//$config['smtp_crypto'] = 'ssl' -
@RiggsFolly 我已经尝试过了。正如我在问题中解释的那样,它给出了错误
fsockopen(): SSL operation failed with code 1. OpenSSL Error messages: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol -
您是否尝试过使用 TLS,大多数大型电子邮件服务器在 SSL 恐慌之后都采用了这种方式See this answer
标签: php codeigniter email wampserver sendmail.exe