16

I would like to be able to send mail to remote servers, from scripts running on my VPS via SMTP, but otherwise reject all incoming mail with postfix on Debian squeeze.

(And in general disable any other features for now. I would like to avoid security risks, provided that I have default settings except for the domain name and don't need anything but sending some mails anyway. Another main concern is that I'm currently very short on time.)

2 Answers 2

28

You can use the inet_interfaces directive in /etc/postfix/main.cf to control what address Postfix listens on for incoming connections. If you set it to the following it will only listen on the loopback interface, which means that connections can only originate from that machine.

inet_interfaces = loopback-only
5
  • That's actually really good if you're only using Postfix for sending out emails. Might not be what you want if you want incoming mail... Commented Aug 9, 2012 at 20:04
  • 7
    @MatthiasHryniszak Which is what the OP asked for.
    – mgorven
    Commented Aug 9, 2012 at 20:23
  • sorry for late accept, I thought I did! thanks again. :)
    – n611x007
    Commented Jun 12, 2013 at 21:06
  • On some platforms, it may be necessary to use the string localhost instead of the string loopback-only.
    – user11574
    Commented Dec 22, 2017 at 21:26
  • 1
    Just because I searched it, a reload of postfix on Ubuntu 16.04 is not sufficient, you must stop & start it to apply inet_interfaces change. Viewed in syslog after a sudo postfix reload : Mar 28 11:20:15 server postfix/master[2304]: warning: service smtp: ignoring inet_interfaces change Mar 28 11:20:15 server postfix/master[2304]: warning: to change inet_interfaces, stop and start Postfix
    – Axi
    Commented Mar 28, 2019 at 10:24
10

You can disable incoming SMTP by editing master.cf, just comment out the smtp and submission services. This will tell postfix not to spawn an smtpd process, which would listen on port 25 (587 for submission) for incoming SMTP connections.

1
  • 2
    Is local mail still delivered if you do this?
    – Michael S
    Commented Apr 29, 2020 at 20:22

You must log in to answer this question.

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