Postfix configuration: how to manage locally sent email from cron jobs?

12
2013-08
  • GJ.

    I set up Postfix on a Debian server serving from mydomain.com and configured it to send out emails from mydomain.com email addresses.

    Since switching to this configuration, my gmail started to be flooded by emails of the outputs of cronjobs that run on my user account on the server. Apparently, the emails get automatically sent to [email protected] which Postfix sends out instead of keeping locally for the "me" debian user account email.

    How can I change the configuration so that such emails only remain in the local mailbox of the user on the server?

  • Answers
  • Alex R

    Those emails are actually sent to the local root user, which perhaps you have inadvertently aliased to [email protected] Check /etc/aliases. There's a number of other things you could have got wrong also. Do you have virtual hosts? What's your mydestination set to? What the envelope 'From' address on those emails?


  • Related Question

    osx - How do I configure the built-in Postfix on Mac OS X to not connect directly to destination hosts other than itself?
  • Kevin Reid

    I run cron jobs on my Mac laptop, and so I want the mail daemon to be able to send the output mail to my regular mail account. I've got that working (my local account has a .forward file), but I'm often on networks where connecting to the destination's MX on port 25 doesn't succeed.

    Therefore, I would like to have the local mail daemon send its outgoing mail, regardless of the destination, to another SMTP server (which happens to be a SSH port-forward to a server under my control). How do I configure the Apple-supplied Postfix to do this?

    Update:

    I tried setting relayhost = [localhost]:40125 (where 40125 is the SSH port forward), but while I can now send mail to a proper Internet mail address (e.g. [email protected]), cron job mail (which is addressed to kpreid@<whatever the DHCP hostname is>) doesn't get delivered. From the one bounce I saw, it appears that this causes all mail, even for the local hostname, to go to the relayhost first.

    Therefore, I need a way to relay to [localhost]:40125 unless the address domain is this machine's domain (which varies frequently).


  • Related Answers
  • JanC

    You need to set the relayhost directive in /etc/postfix/main.cf (and maybe tweak some other settings, but that's hard to say without knowing the default config from Apple).