Setup Postfix as a null client

best practicesemailpostfixsmtp

I'm having a bit of trouble setting up postfix as a null client and have some questions.

I'll be aiming to use SMTP as this is what most web applications use as a way to connect to the email server.

The goal is to use it for email notifications from web applications and monitoring software on the machine.

  1. Are things like SASL and TLS needed? It sounds like encrypting the connection between my web application and the email server is uesless when they're on the same box.
  2. Which user should I connect to the SMTP server as? I originally used the user account I use for daily activities, but this screams bad as my login information is in the wild if my web application is ever cracked. I also tried creating a user with /usr/sbin/nologin as it's shell, but this didn't work either (I'd prefer it the user didn't have shell access).

Any other things to think about while doing this?

Best Answer

I believe what you are asking is for a way to have the mail server accept e-mail that you generate from your web application on the same machine and deliver it to the final destination? I'm not entirely sure because "null client" and your description don't make sense together to me.

Anyway, the way this would typically be done is that in postfix you set "mynetworks" to include "127.0.0.1", and you have your web applications connect to "127.0.0.1" to send e-mail. Mail coming from a host listed in "mynetworks" is not limited in it's ability to send e-mail to only user-names the postfix server directly handles, so you can have your web applications mail your normal e-mail account, or other external users.

mynetworks usually contains 127.0.0.1, so this is likely to be the default configuration.

So, use "postconf mynetworks" to see the current value. Change /etc/postconf/main.cf or use "postconf" to change the value and then restart postfix. Check the logs if your mail still isn't working then.

Related Topic