I am trying to send email from my gmail id to another email id from codeigniter using WAMP localhost.
I am getting the following error
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.
This is the email sending code in my controller function
$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());
these are the settings i did in php.ini
file which were suggested in old posts.
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"
These are the other things i tried that also didnt work
using sendmail and mail instead of
$config['protocol'] = 'smtp';
which produced following error respectively(mail)
Unable to send email using PHP mail(). Your server might not be configured to send mail using this method.
(sendmail)
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.
changing port 465 to 25 and 587 which produce the following error
220 smtp.gmail.com ESMTP v78sm12109697wmv.27 - gsmtp
Adding
$config['smtp_crypto'] = 'ssl';
which produces the following errorfsockopen(): SSL operation failed with code 1. OpenSSL Error messages: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol
Disabling firewall, antivrus etc
Enabling
IMAP
andPOP
from Gmail account
I have no idea what am i doing wrong or what am i missing. Any suggestions would be extremly helpful
These are the some previous posts that i came across and tried but didnt work