使用 Wamp 在 codeigniter 中发送电子邮件时出错
Error while sending email in codeigniter with Wamp
我正在尝试使用 WAMP 本地主机将电子邮件从我的 gmail id 发送到来自 codeigniter 的另一个电子邮件 id。
我收到以下错误
hello: F
The following SMTP error was encountered: F
Unable to send email using PHP SMTP.
Your server might not be configured to send mail using this method.
这是我控制器函数中的邮件发送代码
$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';
分别产生以下错误
(邮件)
Unable to send email using PHP mail(). Your server might not be
configured to send mail using this method.
(发送邮件)
Exit status code: 1 Unable to open a socket to Sendmail. Please check
settings. Unable to send email using PHP Sendmail. Your server might
not be configured to send mail using this method.
将端口 465 更改为 25 和 587 会产生以下错误
220 smtp.gmail.com ESMTP v78sm12109697wmv.27 - gsmtp
添加 $config['smtp_crypto'] = 'ssl';
会产生以下错误
fsockopen(): SSL operation failed with code 1. OpenSSL Error messages:
error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol
禁用防火墙、杀毒软件等
从 Gmail 帐户启用 IMAP
和 POP
我不知道我做错了什么或者我错过了什么。任何建议都会非常有帮助
这些是我之前遇到并尝试但没有奏效的一些帖子
- Codeigniter not connecting to my SMTP server
- Send email using XAMPP and codeigniter
- GMail fsockopen(): SSL operation failed error with Codeigniter and
XAMPP
- 还有更多
像从 localhost 一样在本地发送邮件需要邮件服务器,例如 Fake SendMail。
由于 Google Mail 已更改其 SSL 安全性并删除了对 Sendmail.exe 使用的 v2 的支持,那些将要配置其 GMail 帐户的人也需要配置 Stunnel。
您需要:
- WAMP 服务器 64 位
- Fake Sendmail for Windows
- 任何电子邮件提供商的电子邮件帐户,我使用的是 GMail 帐户。
- Stunnel(如果 Fake Sendmail 本身不起作用)
sendmail.ini
设置如下:
smtp_server=smtp.gmail.com # if gmail, if configured with stunnel use localhost
smtp_port=465 # if gmail, if configured with stunnel use 25
smtp_ssl=auto # if gmail, if configured with stunnel use none
auth_username=youremail@gmail.com
auth_password=yourpassword
有关 Stunnel
配置和更多信息,请参阅 CONFIGURE SENDMAIL WITH WAMP
我正在尝试使用 WAMP 本地主机将电子邮件从我的 gmail id 发送到来自 codeigniter 的另一个电子邮件 id。
我收到以下错误
hello: F
The following SMTP error was encountered: F
Unable to send email using PHP SMTP.
Your server might not be configured to send mail using this method.
这是我控制器函数中的邮件发送代码
$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';
分别产生以下错误(邮件)
Unable to send email using PHP mail(). Your server might not be configured to send mail using this method.
(发送邮件)
Exit status code: 1 Unable to open a socket to Sendmail. Please check settings. Unable to send email using PHP Sendmail. Your server might not be configured to send mail using this method.
将端口 465 更改为 25 和 587 会产生以下错误
220 smtp.gmail.com ESMTP v78sm12109697wmv.27 - gsmtp
添加
$config['smtp_crypto'] = 'ssl';
会产生以下错误fsockopen(): SSL operation failed with code 1. OpenSSL Error messages: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol
禁用防火墙、杀毒软件等
从 Gmail 帐户启用
IMAP
和POP
我不知道我做错了什么或者我错过了什么。任何建议都会非常有帮助
这些是我之前遇到并尝试但没有奏效的一些帖子
- Codeigniter not connecting to my SMTP server
- Send email using XAMPP and codeigniter
- GMail fsockopen(): SSL operation failed error with Codeigniter and XAMPP
- 还有更多
像从 localhost 一样在本地发送邮件需要邮件服务器,例如 Fake SendMail。
由于 Google Mail 已更改其 SSL 安全性并删除了对 Sendmail.exe 使用的 v2 的支持,那些将要配置其 GMail 帐户的人也需要配置 Stunnel。
您需要:
- WAMP 服务器 64 位
- Fake Sendmail for Windows
- 任何电子邮件提供商的电子邮件帐户,我使用的是 GMail 帐户。
- Stunnel(如果 Fake Sendmail 本身不起作用)
sendmail.ini
设置如下:
smtp_server=smtp.gmail.com # if gmail, if configured with stunnel use localhost
smtp_port=465 # if gmail, if configured with stunnel use 25
smtp_ssl=auto # if gmail, if configured with stunnel use none
auth_username=youremail@gmail.com
auth_password=yourpassword
有关 Stunnel
配置和更多信息,请参阅 CONFIGURE SENDMAIL WITH WAMP