1
votes

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.

1
I would say you need version 1.2 or even v3. Check this q/a.Tpojka

1 Answers

6
votes

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";