When users sign up to my site, the connection from my server to our 3rd-party SMTP provider is very bad and the app takes from a few seconds to a few minutes to connect. While it is trying to connect and send, users are forced to wait there and sometimes they would just give up and leave the site.
This is horrible user experience. What is a good way to make this seem instantaneous (having to host our own mailserver is not an option at this point)? Some way to execute this in the background? Maybe using some type of queuing mechanism?
I'm using the LNAMP stack on a CentOS 5 x64 machine. App is using CodeIgniter.
EDIT:
It seems using a local mailserver to use as a relay is a common solution. But how does one log or track whether or not email was delivered correctly by using this method?
Sidenote: Some ESPs provide a REST API for email delivery (ours do too). We currently use SMTP and not their REST API.
Run a local sendmail/qmail/postfix - whatever, set the smtp server to localhost. The local MTA will queue and deliver when it can (right away or at the next queue run).
On your system:
shoudl suffice.
I know bubke about CodeIgniter, so I cant help you there.
You can use Postfix as a nullmailer (relay only to ISP). This is nothing more than a four-liner:
main.cf
Reference: http://www.postfix.org/STANDARD_CONFIGURATION_README.html#null_client
Not sure how common it (good practise) is but sending an email is a typical asynchronous process. One that can take several seconds and beyond. This makes it a perfect candidate for the use of messaging queue.
The delivery method is of secondary importance but third party providers such as SendGrid (for transactional emails - forgotten password, invoice etc) or MailChimp (for newsletters and marketing) offer good value and has proven reliable.
By messaging queue I mean RabbitMQ (AMQ), ZeroMQ, Gearman, AWS SQS etc Those can be used for any sort of information exchange between applications. In this case it's an information that certain email needs sending.
In terms of delivery information this can be obtained through an API with such provider or with more expensive plans through callback.