Using Fastmail with CodeIgniter

249 words, 1 mins

Using Fastmail with CodeIgniter

Details

I recently switched a client’s site from using it’s own Postfix mail system to using Fastmail. More on the reasons for this below, but this is just a quick note on what I need to do to get this running. The Fastmail pages are rather short on the settings needed to communicate from a web application, in this case a CodeIgniter based application.

This is what I have in my app/config/email.php file:

1
2
3
4
5
6
7
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'smtp.fastmail.com';
$config['smtp_port'] = 465;
$config['smtp_user'] = 'bookings@mydomain.com';
$config['smtp_pass'] = 'my-app-password';
$config['smtp_crypto'] = 'ssl';
$config['smtp_timeout'] = '5';

Plus remember to open up the port 465 inbound/outbound on the firewall, if there is one.

Reasons

The website is hosted on Digital Ocean, an excellent hosting company that has run my websites for a number of years, without problems. Except for one little shortcoming… because of their business model (rapid and easy setup of websites and containers) they become a haven for spammers and scammers and that means an increasing number of ISPs simply block all Digital Ocean IP numbers. So there needs to be an external SMTP handler at least, or in this case, just pass the whole thing off to Fastmail. Why Fastmail? I suggested a few others to the client but they are not happy about Google or Microsoft, and Fastmail seemed competent and competitive without the baggage of the larger companies. It was also my recommendation!