i have a simple config email for send an email.
$this->load->library('email');
$config['smtp_crypto'] = 'tls';
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'smtp.gmail.com';
$config['smtp_port'] = 587;
$config['smtp_timeout'] = '5';
$config['smtp_user'] = 'hi*****y#gmail.com';
$config['smtp_pass'] = '*****';
$config['charset'] = 'utf-8';
$config['newline'] = "\r\n";
$config['mailtype'] = 'html'; // or html
// $config['validation'] = TRUE; // bool whether to validate email or not
$this->email->initialize($config);
$message = "content";
$this->email->from("hikmatfauzy#gmail.com", "judul");
$this->email->to("hikmatfauzy7#gmail.com");
$this->email->subject("judul");
$this->email->message($message);
$this->email->send();
echo $this->email->print_debugger();
I get this error message below. how can i do?
i tried on my xampp server but running well. but on IIS i got this error.
A PHP Error was encountered
Severity: Warning
Message: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
Filename: libraries/Email.php
Line Number: 1703
NOTE:
I changed $config['smtp_port'] from 465/587/25 (still got the
error).
I changed my php.ini openssl extension (still got the
error).
Related
I was successfully using Mandrill to send mail from my CodeIgniter site, with this config :
$config['mailtype'] = "html";
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'smtp.mandrillapp.com';
$config['smtp_user'] = 'user';
$config['smtp_pass'] = 'password';
$config['smtp_port'] = '587';
$this->email->initialize($config);
But Mandrill doesn't want to do transactionnal email, so I need to migrate to SparkPost.
Here are their directives : https://support.sparkpost.com/customer/en/portal/articles/1988470-smtp-connection-problems
I tried this config :
$config['mailtype'] = "html";
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'smtp.sparkpostmail.com';
$config['smtp_user'] = 'user';
$config['smtp_pass'] = 'password';
$config['smtp_port'] = '587';
$this->email->initialize($config);
But no mail where send, with no error. So I tried to add "tls" in the host :
$config['smtp_host'] = 'tls://smtp.sparkpostmail.com';
And I get this error :
Message: fsockopen(): SSL operation failed with code 1. OpenSSL Error messages:
error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number
Filename: libraries/Email.php
Line Number: 1950
I got the same error on port 2525.
Here is my openssl section in phpinfo on my local MAMP server :
OpenSSL support enabled
OpenSSL Library Version OpenSSL 0.9.8zg 14
July 2015 OpenSSL Header Version OpenSSL 0.9.8r 8 Feb 2011
But I have the same error on my Debian server, with phpinfo :
OpenSSL support enabled
OpenSSL Library Version OpenSSL 1.0.1e 11 Feb 2013
OpenSSL Header Version OpenSSL 1.0.1e 11 Feb 2013
Openssl default config /usr/lib/ssl/openssl.cnf
Any clue ?
Thanks a lot.
I was close:
SparkPost needs TLS and not SSL. It has to be setted in the parameters, and not in the server url, so that it use STARTTLS. And, last thing, I needed to change the default newline value. So here is the good config:
$config['mailtype'] = "html";
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'smtp.sparkpostmail.com';
$config['smtp_user'] = 'user';
$config['smtp_pass'] = 'password';
$config['smtp_crypto'] = 'tls';
$config['smtp_port'] = '587';
$condig['crlf'] = "\r\n";
$config['newline'] = "\r\n";
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'smtp_host';
$config['smtp_port'] = 25;
$config['smtp_user'] = 'smtp_user';
$config['smtp_pass'] = '$$$';
$this->load->library('email', $config);
$this->email->initialize($config);
$this->email->from($config['smtp_user']);
$this->email->to('aaaa#test.com');
$this->email->subject('TEST MAIL');
$this->email->message('TESTING OF MAIL');
if ($this->email->send()) {
return true;
} else {
return false;
}
This is my code for sending email. I got below error.
Message: fsockopen(): unable to connect to box334.bluehost.com:25 (A connection attempt failed because the connected party did not properly
respond after a period of time, or established connection failed
because connected host has failed to respond. )
You email server is not responding properly. try to check your email server setting like smtp PORT, SMTP HOST and USER etc.
i am using php mailer in Codeigniter.
here is my email settings
mail was sending to other email id but not sending to email id which is in office 365.
<?php defined('BASEPATH') OR exit('No direct script access allowed.');
$config['useragent'] = 'PHPMailer'; // Mail engine switcher: 'CodeIgniter' or 'PHPMailer'
$config['protocol'] = 'smtp'; // 'mail', 'sendmail', or 'smtp'
$config['mailpath'] = '/usr/sbin/sendmail';
$config['smtp_host'] = 'smtp.office365.com';
$config['smtp_user'] = 'example#example.com';
$config['smtp_pass'] = 'password';
//$config['smtp_port'] = 587;
$config['smtp_timeout'] = 5; // (in seconds)
$config['smtp_crypto'] = 'tls'; // '' or 'tls' or 'ssl'
$config['smtp_debug'] = 4; // PHPMailer's SMTP debug info level: 0 = off, 1 = commands, 2 = commands and data, 3 = as 2 plus connection status, 4 = low level data output.
$config['wordwrap'] = true;
$config['wrapchars'] = 76;
$config['mailtype'] = 'html'; // 'text' or 'html'
$config['charset'] = 'ISO-8859-15'; // 'UTF-8', 'ISO-8859-15', ...; NULL (preferable) means config_item('charset'), i.e. the character set of the site.
$config['validate'] = true;
$config['priority'] = 3; // 1, 2, 3, 4, 5; on PHPMailer useragent NULL is a possible option, it means that X-priority header is not set at all, see https://github.com/PHPMailer/PHPMailer/issues/449
$config['crlf'] = "\n"; // "\r\n" or "\n" or "\r"
$config['newline'] = "\n"; // "\r\n" or "\n" or "\r"
$config['bcc_batch_mode'] = false;
$config['bcc_batch_size'] = 200;
$config['encoding'] = '8bit'; // The body encoding. For CodeIgniter: '8bit' or '7bit'. For PHPMailer: '8bit', '7bit', 'binary', 'base64', or 'quoted-printable'.
i have the following error
Connection: opening to smtp.office365.com:25, timeout=5, options=array ( ) 2016-01-02 10:00:49 SMTP ERROR: Failed to connect to server: Connection refused (111) 2016-01-02 10:00:49 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting bool(false)
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
same setting are working in other servers, but not working in Go daddy server.
i checked openssl connection was enabled.
There are many duplicates of this question, and it's also covered in the PHPMailer docs: GoDaddy blocks outbound email, so you have to use their mail servers.
Mandrill working fine in my localhost, but not on server. The following SMTP error was encountered: 110 Connection timed out.I'm working in codeigniter.
Here's my email config file :
$config['mailtype'] = 'html';
$config['charset'] = 'utf-8';
$config['priority'] = 1;
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'smtp.mandrillapp.com';
$config['smtp_port'] = '587';
$config['smtp_user'] = 'abcdefgh#gmail.com';
$config['smtp_pass'] = 'xxxxxxxxxxxxxxxxxxxxxx';
The mails are received wen sending from localhost. I tried debugger.and i receive the above error. Please help!!! What could be the reason??
i think the port is blocked, try this in any controller:
$connection = #fsockopen('smtp.mandrillapp.com', 587);
if (is_resource($connection)){
echo 'open';
fclose($connection);
}else{
echo 'closed';
}
i've already had this problem while i'm implementing mandrill on my web app.
While sending an email, I'm receiving a bunch of such errors:
A PHP Error was encountered
Severity: Notice
Message: fwrite(): send of 12 bytes failed with errno=32 Broken pipe
Filename: libraries/Email.php
Line Number: 1846
A PHP Error was encountered
Severity: Notice
Message: fwrite(): send of 39 bytes failed with errno=32 Broken pipe
Filename: libraries/Email.php
Line Number: 1846
A PHP Error was encountered
Severity: Notice
Message: fwrite(): send of 31 bytes failed with errno=32 Broken pipe
Filename: libraries/Email.php
Line Number: 1846
I have followed the CodeIgniter user guide to configure an SMTP:
$config['protocol']='smtp';
$config['smtp_host']='ssl0.ovh.net';
$config['smtp_port']='465';
$config['smtp_timeout']='10';
$config['smtp_user']='postmaster%example.com';
$config['smtp_pass']='password';
$config['mailtype'] = 'html';
$config['charset'] = 'utf-8';
$config['newline'] = "\r\n";
$config['useragent'] = 'Project';
It seems like the configuration file is just fine, and correct (I've checked the OVH's email configuration files).
Any solution for that?
I too was in the same situation. Was getting:
Message: fwrite(): SSL: Broken pipe</p><p>Filename: libraries/Email.php</p><p>Line Number:
2250&
the change that really made a difference was the 'smtp_crypto' config option set to 'ssl'
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://example.com';
$config['smtp_crypto'] = 'ssl';
$config['smtp_port'] = '465';
$config['smtp_user'] = 'user#example.com';
$config['smtp_pass'] = 'password';
$config['mailtype'] = 'html';
$config['charset'] = 'iso-8859-1';
$config['wordwrap'] = 'TRUE';
I found this solution at https://www.codeigniter.com/user_guide/libraries/email.html by searching for SSL option.
This is the answer that worked for me
http://biostall.com/resolving-error-with-sending-emails-via-smtp-using-codeigniter/
Be sure to use "\r\n" and not '\r\n'
Also you can set this in a config file:
$config['newline'] = "\r\n";
$config['crlf'] = "\r\n";
If you are using cpanel for your website smtp restrictions are problem and cause this error.
SMTP Restrictions
This feature prevents users from bypassing the mail server to send
mail, a common practice used by spammers. It will allow only the MTA,
mailman, and root to connect to remote SMTP servers.
This control is also adjustable in Tweak Settings.
This setting has been updated.
The SMTP restriction is disabled.
I had a similar problem and had to disable SMTP Restrictions.
After that all was ok.
As far as CI is concerned, there are so many issues with your email config array that could cause this error.
If you are on local development enviroment, Try changing capitalization for "smtp" to "SMTP" with capital letters.
If you are on a live server, try changing them to small caps.
All in all playing with $config['protocol'] = 'smtp' capitalization some times helps.
Same problem here... but what worked for me was these set of configuration:
$config['protocol'] = 'smtp';
$config['smtp_host'] = XXX;
$config['smtp_user'] = XXX;
$config['smtp_port'] = 25; // was 465
$config['smtp_pass'] = XXX;
$config['newline'] = "\r\n";
And the message stopped. :D
use smpt_port:25, it's worked for me
I try this and it's work for me
$config['protocol'] = 'smtp';
$config['smtp_crypto'] = 'tls';
$config['smtp_host'] = 'smtp.gmail.com';
$config['smtp_port'] = '587';