I'm in the middle of a never-ending migration of a 16-year-old site to CodeIgniter 4 (which has numerous nontrivial problems). I see that in the past, the server was configured such that Postfix would route all mail off the machine and try to deliver it via Amazon SES. That being the case, the PHP mail() function works and mail is routed via Postfix to the SES gateway. If I'm not mistaken, this approach has the nice feature that PHP will return almost instantly from a mail() function call when Postfix accepts the mail almost instantly. Postfix has its own log which can be quite useful for troubleshooting problems.

However, CI4 supports SMTP mail delivery and Amazon SES offers an SMTP gateway. This seems a lot less complicated than configuring postfix. On the other hand, all those emails generated by the system (e.g. samhain or cron job errors) would not benefit from PHP using SMTP.

I'm curious what approach others might be using for their servers? Do you have a preferred email service (e.g., MailChimp, SendGrid, AmazonSES)? Do you have a preferred MTA (e.g., Postfix, Sendmail, Qmail)? What's your interface between PHP and your mail system (e.g., mail function, SMTP client, etc)?

    I've always used PHPMailer to handle SMTP stuff (not saying it's the best, just that I used it because I knew it ๐Ÿ™‚ ), and performance has seemed fine for my needs. It's always been for generally simple stuff: user submits form, data is processed, something is stuck into an email message and set to someone via SMTP. If you're talking more mass mailing of stuff to (insert large number) of recipients, I have no experience with that.

    NogDog Do you ever see a slow response from the remote SMTP server? And what mail service do you use? Do you ever bother to configure your server to route system emails (e.g., to root from local system processes) to an actual email address? Any anecdotes would be appreciated.

      Really all I've ever used is either something like my personal Gmail account for little personal projects, or for the couple things on my job (like change password functionality for end users) it uses a SMTP mail account I was given to use from our IT team -- I have no idea what mail service actually underlies it.

      I recall at some point a few years ago I had some problem or other, and happily discovered that PHPMailer had an ability to gather/display a lot more debug info than mail() does (e.g. see https://github.com/PHPMailer/PHPMailer/wiki/SMTP-Debugging) -- but really I'm far from an expert on this (as you can tell? ๐Ÿ˜‰ ).

      a month later

      Our site originally used PHPMailer I think (when it was OOB software); then used mail() (Sendmail on localhost) for a while after we started heavy customization, and then I migrated (back) to PHPMailer a few years ago because tests seemed to indicate we had better deliverability that way (As I recall we could attach SPF information to it?)

      As to what I'm doing now, it seems to vary a little and mail from a webserver isn't any critical portion of our work....

      12 days later

      dalecosp I migrated (back) to PHPMailer a few years ago because tests seemed to indicate we had better deliverability that way (As I recall we could attach SPF information to it?)

      Thanks for this detail. Deliverability is always a problem with any server I've ever dealt with. I guess it stands to reason that you'd get better mail delivery rates if you connect to gmail or something and have your server send it from there. As for SPF records, I have complete control of all the DNS and have always tried to use reputable-looking SPF validators to make sure I'm setting up the right SPF records. I've also tried to set up domain keys and all that.

      Most recently, I configured our Ubuntu servers with Postfix and, through laborious and confusing configuration efforts, have set the servers up to route all email off those machines to Amazon SES via an SMTP gateway they have. This seems to work for me -- I always seem to get even the most trivial email delivered promptly from the machine to my gmail account. But some of our users just never get the emails for some reason. Email delivery is a tricky business.

        a year later

        I apologize to the mods for posting in this old thread, but I discovered today that Google changed its mail authentication policy and appears to be blocking password authentication. As stated here

        To help keep your account secure, from May 30, 2022, โ€‹โ€‹Google no longer supports the use of third-party apps or devices which ask you to sign in to your Google Account using only your username and password.

        Important: This deadline does not apply to Google Workspace or Google Cloud Identity customers. The enforcement date for these customers will be announced on the Workspace blog at a later date.

        I've been sniffing around my gmail account's security settings and under the 'Less secure app access' option it reads 'This setting is no longer available.' I sniffed around a bit more and finally figured out that, if you turn on 2FA, gmail will give you the option to generate 'App Passwords' which you can use to delegate access to your gmail account. I was able to generate such a password and simply replace my own password in my PHP app's SMTP config.

          Write a Reply...