1

Topic: catch-all address forwarded to script not working

==== Required information ====
- iRedMail version (check /etc/iredmail-release): 0.9.2
- Linux/BSD distribution name and version: Ubuntu 14.04.3 LTS, Trusty Tahr
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): MySQL
- Web server (Apache or Nginx): Apache
- Manage mail accounts with iRedAdmin-Pro? Not yet
- Related log if you're reporting an issue: dont know yet?
====

Here is what I did:

- Created a new user on my domain using iRedAdmin

- Made the new account a catch-all account by following http://iredmail.org/docs/sql.create.catch-all.html

- Catch all seems to do its job ie. catching incoming emails from non-existing accounts that I can confirm using mail client

- Then, I followed the instructions at http://iredmail.org/docs/pipe.incoming. … cript.html to pipe incoming emails to a script. However, that does not seem to work for me. Did I do something wrong? How do I troubleshoot it? I did not find much info in mail.log

=========================
Web: http://geeksww.com

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: catch-all address forwarded to script not working

*) Any error message/log?
*) Please show us what you exactly changed.

3 (edited by syedshahryar 2015-11-18 21:12:40)

Re: catch-all address forwarded to script not working

Here is what I did (replaced actual domain name with example.com):

- I created a catch@example.com account using iRedAdmin

- My vmail.alias mysql table is like:

address goto    name    moderators      accesspolicy    domain  islist  created modified        expired active
postmaster@example.com  postmaster@example.com          NULL            example.com     0       2015-11-17 18:45:24     0000-00-00 00:00:00     9999-12-31 00:00:00     1
example.com     catch@example.com               NULL            example.com     0       2015-11-17 21:52:20     0000-00-00 00:00:00     9999-12-31 00:00:00     1
catch@example.com       catch@example.com               NULL            example.com     0       2015-11-18 02:54:45     0000-00-00 00:00:00     9999-12-31 00:00:00     1

- Tested incoming emails and they seem to work fine.

- Then, added following information at the very bottom of /etc/postfix/master.cf

# tail -n 2 /etc/postfix/master.cf
external-pipe   unix    -   n   n   -   -   pipe
  flags= user=vmail:vmail argv=/script.sh

- Made sure script.sh is executable and has no issues (contents below):

#!/bin/sh
echo 'mail' >> /tmp/out

- Restarted postfix (no errors)

- The script does not get executed (ie. /tmp/out is not modified) but I do receive emails. I also tried using a regular OS user.


=========================
Web: http://geeksww.com

4

Re: catch-all address forwarded to script not working

turns out there is more info on the page under the big image that I missed.

It seems to work after running the mysql UPDATE.

However, is it possible to also forward email to the user (and the script)? Script seems to be executed now but email is not sent to catch all anymore.

5

Re: catch-all address forwarded to script not working

Replace your 'flags=' in /etc/postfix/master.cf by 'flags=DRhu', restart postfix and try again.

By the way, full email content will be piped to your script like below, make sure your script can correctly handle it.

bash script.sh < /path/to/plain_file

6

Re: catch-all address forwarded to script not working

I did make the suggested change and restarted postfix/system but it didn't work though:

tail -n 2 /etc/postfix/master.cf
external-pipe   unix    -   n   n   -   -   pipe
  flags=DRhu user=vmail:vmail argv=/script.sh

The email does not get forwarded to catch all account.


I am going to use PHP to parse email content. See http://www.phpshare.org/articles/Piping … l-with-PHP


Another question:  I can receive emails sent by other clients but sent emails (thru iRedMail) are not received by Gmail or Hotmail. I've made sure DKIM keys are fine (amavisd-new testkeys).

How do I troubleshoot this problem?

7

Re: catch-all address forwarded to script not working

*) If it doesn't work, please show us related error log in Postfix log file.

syedshahryar wrote:

Another question:  I can receive emails sent by other clients but sent emails (thru iRedMail) are not received by Gmail or Hotmail. I've made sure DKIM keys are fine (amavisd-new testkeys).

Any related error in Postfix log file?

8

Re: catch-all address forwarded to script not working

No relevant error messages in /var/log/mail.err

mail.log contains following relevant entries:

Nov 19 08:07:08 mx postfix/smtp[2499]: connect to gmail-smtp-in.l.google.com[173.194.208.26]:25: Connection timed out
Nov 19 08:07:38 mx postfix/smtp[2499]: connect to alt1.gmail-smtp-in.l.google.com[64.233.186.27]:25: Connection timed out
Nov 19 08:08:08 mx postfix/smtp[2499]: connect to alt2.gmail-smtp-in.l.google.com[74.125.24.26]:25: Connection timed out
Nov 19 08:08:38 mx postfix/smtp[2499]: connect to alt3.gmail-smtp-in.l.google.com[64.233.166.27]:25: Connection timed out
Nov 19 08:09:08 mx postfix/smtp[2499]: connect to alt4.gmail-smtp-in.l.google.com[74.125.136.26]:25: Connection timed out
Nov 19 08:09:08 mx postfix/smtp[2499]: 4B78J0420F: to=<.......@gmail.com>, relay=none, delay=150, delays=0.01/0.02/150/0, dsn=4.4.1, status=deferred (connect to alt4.gmail-smtp-in.l.google.com[74.125.136.26]:25: Connection timed out)


Also, I used a diagnostics tool that was showng warning on "SMTP Banner Check".

9

Re: catch-all address forwarded to script not working

The log means your server cannot connect to Gmail server. Please make sure your ISP doesn't block port 25, and make sure your firewall doesn't block it too.

10

Re: catch-all address forwarded to script not working

Thanks. I will work on getting that fixed.

And, what about the other issue of catch-all not receiving emails forwarded to a script?