space
advocacy.gif
menu_top_inactive.gif space
Piping commands for PostFix in Mac OS X Server
2007-05-08 13:03:17
Keywords: Server, 578 hits

Piping commands for PostFix in Mac OS X Server
I am writing this in English since I've looked high end low for a solution to this online and now that I have it figured out I thought I'd just post it here for Google to index so it can help others.

Basically, what I wanted to do was to have mail sent to a specific address piped to a perl script. I own the domain "sandman.net" and I wanted mail to "mailinglist@sandman.net" to be piped to my selfbuilt mailinglist manager, which resides, on the server, in path "/Users/sandman/MailExec/list.pl"

Coming from a sendmail background, I have messed around with /etc/mail/virtusertable and /etc/aliases to achieve this, but with postfix (the MTA in OSX) it wasn't as straightforward.

Basically, putting this in /etc/postfix/aliases didn't work:

  1. mailinglist: |/Users/sandman/MailExec/list.pl

And would bounce with "no such mailbox". Doing it the other way, in "/etc/postfix/virtual":

  1. mailinglist@sandman.net "|/Users/sandman/MailExec/list.pl"

Did the same. The solution was to make it a two-step process:

  1. /etc/virtual:
  2. mailinglist@sandman.net mailinglist
  3. /etc/aliases:
  4. mailinglist: "|/Users/sandman/MailExec/list.pl"

So, the virtual user table handles the incoming address and pipes it to the local user "mailinglist", which is piped to the perl script in the aliases file. This is the output of my postconf -n:

  1. alias_maps = hash:/etc/aliases
  2. command_directory = /usr/sbin
  3. config_directory = /etc/postfix
  4. content_filter = smtp-amavis:[127.0.0.1]:10024
  5. daemon_directory = /usr/libexec/postfix
  6. debug_peer_level = 2
  7. enable_server_options = yes
  8. html_directory = no
  9. inet_interfaces = all
  10. mail_owner = postfix
  11. mailbox_size_limit = 0
  12. mailbox_transport = cyrus
  13. mailq_path = /usr/bin/mailq
  14. manpage_directory = /usr/share/man
  15. maps_rbl_domains =
  16. message_size_limit = 0
  17. mydestination = $myhostname,localhost.$mydomain,mail.eklundh.com
  18. mydomain = eklundh.com
  19. mydomain_fallback = localhost
  20. myhostname = mail.eklundh.com
  21. mynetworks = 127.0.0.1/32,web.eklundh.com
  22. mynetworks_style = host
  23. newaliases_path = /usr/bin/newaliases
  24. owner_request_special = no
  25. queue_directory = /private/var/spool/postfix
  26. readme_directory = /usr/share/doc/postfix
  27. recipient_delimiter = +
  28. relayhost =
  29. sample_directory = /usr/share/doc/postfix/examples
  30. sendmail_path = /usr/sbin/sendmail
  31. setgid_group = postdrop
  32. smtpd_client_restrictions = permit_mynetworks reject_rbl_client sbl-xbl.spamhaus.org reject_rbl_client relays.ordb.org permit
  33. smtpd_enforce_tls = no
  34. smtpd_pw_server_security_options = cram-md5
  35. smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination,permit
  36. smtpd_sasl_auth_enable = yes
  37. smtpd_tls_cert_file = /etc/certificates/Sandman Mail Service.crt
  38. smtpd_tls_key_file = /etc/certificates/Sandman Mail Service.key
  39. smtpd_use_pw_server = yes
  40. smtpd_use_tls = yes
  41. unknown_local_recipient_reject_code = 550
  42. virtual_alias_maps = hash:/etc/postfix/virtual
  43. virtual_mailbox_domains = hash:/etc/postfix/virtual_domains
  44. virtual_transport = lmtp:unix:/var/imap/socket/lmtp

And after doing any edits to any of these files, issue these commands:
  1. cd /etc/postfix
  2. postmap virtual
  3. postalias aliases
  4. postfix reload

To make the changes active.

Comments
0 comments
space space