-1

I have an AWS EC2 instance running Amazon Linux with Postfix for serving mail. I have only local users -- no virtual users -- and my users and aliases are served via PostgreSQL. My aliases table in psql looks like this:

 alias | email
-------+---------------------------------------------------------------------
 doc   | | /usr/bin/php /var/www/vhosts/mydomain.com/httpsdocs/app/pipe.php

When I send an email to doc@mydomain.com and tail the maillog, I see this:

May 18 21:22:35 ip-172-30-0-33 dovecot: auth: userdb(?): Username character disallowed by auth_username_chars: 0x7c (username: |/usr/bin/php /var/www/vhosts/mydomain.com/httpsdocs/app/pipe.php@mydomain.com)
May 18 21:22:35 ip-172-30-0-33 dovecot: auth: Debug: userdb out: NOTFOUND#0111
May 18 21:22:35 ip-172-30-0-33 dovecot: lmtp(11981): Debug: auth input:
May 18 21:22:35 ip-172-30-0-33 postfix/lmtp[11980]: 9992660E42: to=<|/usr/bin/php /var/www/vhosts/mydomain.com/httpsdocs/app/pipe.php@mydomain.com>, relay=mail.mydomain.com[private/dovecot-lmtp], delay=0.03, delays=0/0.01/0/0.01, dsn=5.1.1, status=bounced (host mail.mydomain.com[private/dovecot-lmtp] said: 550 5.1.1 <|/usr/bin/php /var/www/vhosts/mydomain.com/httpsdocs/app/pipe.php@mydomain.com> User doesn't exist: |/usr/bin/php /var/www/vhosts/mydomain.com/httpsdocs/app/pipe.php@mydomain.com (in reply to RCPT TO command))

Additionally, it doesn't like the pipe character, nor can I wrap the pipe path in quotes, as those are rejected as well.

What's the solution to getting Postfix to forward emails to doc@ to the script when the aliases are in PostgreSQL?

Thanks for any assistance!

(PS - I'm a total noob at all of this, muddling my way through getting this server set up. Please be gentle...)

1 Answers1

1

Taking care of mail transfer with "branching" of transfer chains is the job of a mail transfer agent, which Dovecot is not. I'm not aware Dovecot would support "delivering" mails to pipes at all. Use a real MTA instead, like Postfix or Exim.

If you're stuck with Dovecot, you might be able to build around following alternatives (but I'd strongly recommend plugging Postfix in front of Dovecot, you might have one anyway already):

  • Dovecot's Sieve implementation can be used to filter and process incoming messages while being delivered. Among lots of other operations, Dovecot has a proprietary extension for executing scripts.
  • Write your own Dovecot plugin, but there is few documentation on this.
  • Mail filters will not help you out, as they may not suppress messages (they have to provide bidirectional in and out filters, and applying both must return the original message).
Jens Erat
  • 1,530
  • 2
  • 12
  • 27
  • Thanks, Jens. I'm actually using Postfix + Dovecot. So it's Postfix that's doing the actual delivery, but Dovecot that seems to be having the issue with the pipe. I've seen the pipe extension for Dovecot, but the actual installation and set-up of said extension is a little beyond my ability, insofar as having clear instructions on how to do it. Yet I may just have to put on my big-boy pants and give it a shot. :) – pixelsandcode May 22 '17 at 13:19
  • Configure Postfix to do the pipe delivery. The message should not even reach Dovecot if Postfix already handles it. – Jens Erat May 22 '17 at 15:31
  • Which is what I was attempting to do in the first place, with the `aliases` table. (See above). So somewhere in there, dovecot thinks the alias `|/usr/bin/php /var/www/vhosts/mydomain.com/httpsdocs/app/pipe.php@mydomain.com` is a user and not a pipe. – pixelsandcode May 22 '17 at 19:29