I've been running a web platform that needs to send a considerable amount of emails daily. At the implementation date I and my partner decided to setup Postfix on the server and use Swift Mailer class to send the email using a SMTP connection to the local Postfix server.
This allowed us to have multiple email accounts, like [email protected]
, [email protected]
, [email protected]
and be able to send email with them correctly signed with DKIM.
My question is, can't we configure PHP in some way to avoid a local SMTP connection (which takes time an server resources) and replace with a more direct way to deliver the messages to be sent to the Postfix queue?
Form my understanding I could use PHP mail()
function or even Swift Mailer's Swift_SendmailTransport
class and deliver the messages directly to Postfix queue. But if so, how can we ensure DKIM? Will changing the "FROM" header to the email accounts on the local server be enough?
Thank you.
That's true
You doesn't specify your DKIM signer, so I assume that you use OpenDKIM in your setup. OpenDKIM integrate with postfix by milter interface. For signing email from mail() command (without smtp ritual), you need to ensure that OpenDKIM socket/port also listed
non_smptd_milters
.Firstly, so long as you have OpenDKIM specified in non_smptd_milters as well as smptd_milters in Postfix's main.cf, outgoing mail sent through PHP mail() should still be signed. The Received headers are not signed by default, and nothing much else should have been rewritten by cleanup. If you want an alternative method, you could DKIM sign using Amavis and content_filter, although that means even more SMTP sessions.
Secondly, it sounds unlikely to me that using local SMTP rather than dropping the mail into the maildrop queue is such a performance overhead. It could be that you have a limited number of postfix smtpd daemons all of which are calling the milter, but even without that the mail still has to go through the OpenDKIM milter before being sent out. Yes your PHP scripts will finish sooner, but I doubt the email will be delivered any quicker. It may be worth re-reading http://www.postfix.org/QSHAPE_README.html