1

New Ubuntu admin here, trying to enable the PHP mail() function on my server. I have it working, but am wondering if my setup is secure...

My [full] mail solution is as follows:

1) For incoming mail to @mydomain.com, I use email forwarding through my domain host // for outgoing mail, I use an alias on top of a gmail account that appears as if it sends from @mydomain.com

2) For mail generated by my webserver (www-data), which will pretty much just be used to send password resets, it appears to be successfully handled by postfix. The postfix setup is essentially the following, plus a few smtp_tls rules I added in to achieve TLS on outbound emails when possible.

myorigin = $mydomain
mydestination =
mynetworks = 127.0.0.0/8
inet_interfaces = loopback-only

I made some assumptions while doing this config, namely:

  • loopback-only config means NOBODY other than my localhost can send mail through postfix
  • I do not need to specify a relay_host here
  • Since this is outbound only, all smtpd_* config settings are unnecessary
  • Since all requests to send through postfix SMTP is through a PHP script that controls for user input (avoiding injection), this is an inherently secure setup.

Is there anything I'm missing? Any ways to make this setup more secure? I think postfix is overkill for an outbound-only server, but I recently did a ton of reading on postfix configs. Is sendmail a reasonable / simpler alternative? Is there a better package (e.g. nullmailer) to use?

Thanks!

1 Answer 1

1

There may be things you are missing.

With respect of deliver ability, there are a few things a mail server needs to do - like forward and reverse DNS records (as well, ideally, as SPF records). There are also volime/reputation issues wbich may or may not be relevant. My suggestion - don't. Configure postfix to relay to the appropriate MX for yourndomain.

SMTP through an appropriate PHP script is not inherently insecure. The reverse is not necessarily true or false. There may be other attack vectors.

Sendmail was - last time I used it a century ago - much harder to configure and manage then Postfix. Postfix is also designed with security in mind. It is not a bad choice for a send-omly mail server.

2
  • Thanks for this! If I'm understanding correctly, you're suggesting that instead of using postfix as smtp, I should just relay all outbound mail to a different SMTP server to handle the actual sending. Understand that this gives my mail a better shot of not getting flagged for spam, but aside from that, does it fix the volume / reputation issues you mentioned? What's an example of a different SMTP that I can use to handle a no-reply case (e.g. google?)?
    – sevan1028
    Oct 15, 2019 at 15:40
  • 1
    Yes, it will lfix these other issues, because your server is acting like a mail client, mail will be sent to other servers from a "professionally run" server.
    – davidgo
    Oct 15, 2019 at 18:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .