A PHP Error was encountered
Severity: Warning
Message: fsockopen(): unable to connect to ssl://smtp.gmail.com:465 (Permission denied)
$config = array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => 'user',
'smtp_pass' => 'password',
'mailtype' => 'html',
'charset' => 'iso-8859-1'
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
If you're running Red Hat-derivatives, they come with SELinux enabled by default, and probably php-fpm is denied access to create socket. Try checking it by running grep php /var/log/audit/audit.log | grep denied.
If so, you can run /usr/sbin/setsebool httpd_can_network_connect 1 as root, then try to run the code again.
Try defining your EMAIL_SMTP_HOST to
define("EMAIL_SMTP_HOST", "ssl://smtp.gmail.com");
If by chance it doesnt work check your EMAIL_SMTP_PORT it may be different to what you set there
define("EMAIL_SMTP_PORT",225O);
Lastly check if by chance your SSL Certificate is installed in your server,same to the mail server also make sure your cridentials both "SMTP_USERNAME" and "SMTP_PASSWORD" are correct.
Related
I have problems when sending email, I make registration and verification by email, when on localhost everything runs smoothly, there are no problems, but when I am hosting, the email function cannot, please help
$config = array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.gmail.com',
'smtp_port' => 465,
'smtp_user' => 'email#gmail.com', // change it to yours
'smtp_pass' => 'mypassword', // change it to yours
'mailtype' => 'html',
'charset' => 'iso-8859-1',
'wordwrap' => TRUE
);
$message = "
<html>
<head>
<title>Verifikasi Kode</title>
</head>
<body>
<h2>Terima kasih telah berpartisipasi.</h2>
<p>Akun anda:</p>
<p>Email: ".$email."</p>
<p>Untuk melanjutkan pendaftaran, mohon klik link yang kami berikan</p>
<h4><a href='".base_url()."register/aktivasi/".$id."'>Activate My Account</a></h4>
</body>
</html>
";
$this->email->initialize($config);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->from($config['smtp_user']);
$this->email->to($email);
$this->email->subject('Signup Verification Email, abcd.com | No reply');
$this->email->message($message);
if($this->email->send()){
$this->session->set_flashdata('msg','Kode Aktivasi telah dikirim ke email, mohon di cek');
}
else{
$this->session->set_flashdata('msg', $this->email->print_debugger());
}
redirect('register',$data);
}
Error : Failed to authenticate password. Error: 534-5.7.14 Please 534-5.7.14 log in via your web browser and then try again. 534-5.7.14 Learn more at 534 5.7.14 https://support.google.com/mail/answer/78754 18sm13749594pfp.100 - gsmtp
Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.
This issue causes when your access is wrong.
$config = array(
'protocol' => 'smtp',
'smtp_host' => 'smtp.googlemail.com', # Change
'smtp_port' => 587, # Change
'smtp_user' => 'email#gmail.com',
'smtp_pass' => 'mypassword',
'smtp_crypto' => 'tls', # Add
'mailtype' => 'html',
'charset' => 'utf-8',
'wordwrap' => TRUE
);
Make sure: Less secure apps enabled in Gmail and Turn off 2-Step Verification is turned off
You should change the “Access for less secure apps” to Enabled (it will be disabled, changed to enabled). Try it.
Everything going great on Codeigniter localhost but on particuler Plesk Linux Server I get the different type of error as per changing the port number and protocols. I'm really hanging on this problem, also read the documentation of Plesk but I didn't understand. Hope on StackOverflow someone gives a solution.
I tried most of the all port and protocols to get the result but not succeded. Used code
function sendMail()
{
$this->load->library('email');
// ini_set('SMTP', "smtp.rediffmailpro.com");
// ini_set('smtp_port', "25");
// ini_set('sendmail_from', "myemailid");
// curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
// curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$config = array(
// for rediff mail setup
// 'protocol' => 'smtp',
// 'smtp_host' => 'smtp.rediffmailpro.com',
// 'smtp_port' => 587,
// 'smtp_user' => 'email.com',
// 'smtp_pass' => 'pass',
// 'mailtype' => 'html',
// 'charset' => 'iso-8859-1', //'UTF-8'
// 'wordwrap' => TRUE
// for gmail setup
'protocol' => 'smtp', //'mail', 'sendmail', 'tls' tried these but get different type of errors
'smtp_host' => 'smtp.gmail.com', /*'smtp.googlemail.com',*/
'smtp_port' => 587, //465
'smtp_user' => 'user email',
'smtp_pass' => 'user pass',
//'smtp_crypto' => 'smtp',
'mailtype' => 'html',
'smtp_timeout' => 5,
'charset' => 'utf-8',
'wordwrap' => TRUE
);
$this->email->initialize($config);
$this->load->library('email', $config);
$this->email->from('email','AG'); // change it to yours
$this->email->to('your email');// change it to yours
$this->email->subject('Test Mail');
$this->email->message('Dont be pannic.');
$this->email->set_newline("\r\n");
if($this->email->send())
{
echo 'Email sent.';
}
else
{
show_error($this->email->print_debugger());
}
}
At this condition I get this error
Failed to authenticate password. Error: 534-5.7.14 Please log
534-5.7.14 in via your web browser and then try again. 534-5.7.14
Learn more at 534 5.7.14 https://support.google.com/mail/answer/78754
k11sm2916535wmk.45 - gsmtp Unable to send email using PHP SMTP. Your
server might not be configured to send mail using this method.
But on given google url didn't get any idea about my problem or I didn't get it.
After changing
port 465,
smtp_hot "ssl://email.com",
Get this error
Failed to authenticate password. Error: 534-5.7.14 Please log
534-5.7.14 in via your web browser and then try again. 534-5.7.14
Learn more at 534 5.7.14 https://support.google.com/mail/answer/78754
y66sm2047426wmd.37 - gsmtp Unable to send email using PHP SMTP. Your
server might not be configured to send mail using this method.
I don't understand what am I doing wrong.
Want to successfully send mail. On Plesk server
$config = array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.gmail.com',
'smtp_port' => '465',
'smtp_user' => "xxxxxxx#gmail.com",
'smtp_pass' => "xxxxxxx", // change it to yours
'mailtype' => 'html',
'charset' => 'utf8'
);
$this->load->library('email',$config);
$this->email->set_newline("\r\n");
$this->email->set_crlf( "\r\n" );
$this->email->from($config['smtp_user']);
$this->email->to($email['user_email']);
$this->email->subject($row['tplsubject']);
$this->email->message(html_entity_decode($email_subject));
$this->email->send();
This code not working its showing error
A PHP Error was encountered
Severity: Warning
Message: fsockopen(): unable to connect to ssl://smtp.gmail.com:465
(Unable to find the socket transport "ssl" - did you forget to enable
it when you configured PHP?)
Filename: libraries/Email.php
Line Number: 1689
I am facing the same problem with Email on a server, the solution for this problem is to change the 'protocol' from 'smtp' to 'ssmtp' and 'smtp_host' from 'ssl://smtp.gmail.com' to 'ssl://ssmtp.googlemail.com'. This thing is working fine for me.
This is not a codeigniter problem, but a php settings related problem. The answer to this question can be found here: Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?
One thing to note is that in codeigniter you can use an e-mail config file, to hold all your config settings. (so you don't have to define them each time in a controller). You can do this by creating the file: application/config/email.php you can then fill this file with your settings, like this:
<?php defined('BASEPATH') OR exit('No direct script access allowed');
$config = array(
'protocol' => 'smtp', // 'mail', 'sendmail', or 'smtp'
'smtp_host' => 'your_host',
'smtp_port' => your_port,
'smtp_user' => 'your_email',
'smtp_pass' => 'your_password',
'smtp_crypto' => 'security', //can be 'ssl' or 'tls' for example
'mailtype' => 'html', //plaintext 'text' mails or 'html'
'smtp_timeout' => '4', //in seconds
'charset' => 'iso-8859-1',
'wordwrap' => TRUE
);
each time you load the library ($this->load->library('email');) these settings will be automatically loaded.
Also I recommend that you change your e-mail password immediately because you wrote your credentials in your question.
I have had the same issue was trying to connect with yandex smtp sever for sending email and it was showing fsockopen(): unable to connect to ssl://smtp.yandex.ru:465 using codeigniter framework. Adding $this->load->library('email'); before the email send function solved my problem.
i m trying to send email It properly working on localhost
when i live it on server it give me warning
i m using codeigniter here is the code
public function send_me($from,$name,$toEmail,$subject,$msg){
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => 'xxxxxxxxxxx',//user name herer
'smtp_pass' => 'xxxxxxxx', //password hre
'mailtype' => 'html',
'charset' => 'iso-8859-1',
'wordwrap' => TRUE
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->from($from,$name);
$this->email->to($toEmail);//to address here
$this->email->subject($subject);
$this->email->message($msg);
if($this->email->send())
return true;
else
return false;
}
and warning are
A PHP Error was encountered
Severity: Warning
Message: fsockopen() [function.fsockopen]: unable to connect to ssl://smtp.googlemail.com:465 (Connection timed out)
Filename: libraries/Email.php
Line Number: 1689
A PHP Error was encountered
Severity: Warning
Message: fwrite() expects parameter 1 to be resource, boolean given
Filename: libraries/Email.php
Line Number: 1846
I have answered several issues like this one. If your local email is working fine then follow the steps below:
To use Google SMTP in CodeIgniter you need to make 2 (two) changes into your Gmail account setting: (N.B. Please be aware that it is now easier for an attacker to break into your account -says Google)
Set off 2-step Verification.
Allow less secure apps: ON (or Enable)
Now use 'smtp_host' as ssl://smtp.gmail.com instead of smtp.googlemail.com
Hope upcoming users can get this help too.
I have a problem in sending mails using CI. I used the "sendmail" protocol to send mail but it is being filtered as spam. I used the SMTP protocol to solve the problem, but it's not getting sent.
My code is as follows:
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => '*******#gmail.com',
'smtp_pass' => '********',
'mailtype' => 'html',
'charset' => 'iso-8859-1'
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$message = "test mail";
$this->email->set_newline("\r\n");
$this->email->from('dsiddharth2#gmail.com', 'St. Maries');
$this->email->to("dsiddharth2#gmail.com");
$this->email->subject('Contact - St. Marians Belguam');
$this->email->message($message);
if($this->email->send())
{
echo "mail sent successfully";
}
else
{
show_error($this->email->print_debugger());
}
When I send the email using "smtp" protocol in CI, I get the following error:
A PHP Error was encountered
Severity: Warning
Message: fsockopen() [function.fsockopen]: unable to connect to ssl://smtp.googlemail.com:465 (Connection timed out)
Filename: libraries/Email.php
Line Number: 1673
and other list of errors...
I asked the server admin to enable the "openssl". It's been already taken care of and is enabled.
If you want to try it out, please visit this link and check for yourself.
If it's not working, check your php.ini file. Change this line
;extension=php_openssl.dll
to
extension=php_openssl.dll
It means remove the comment from the line in php.ini file.