Mail rules

Hi, A user wants to set up mail rules to move mail matching certain criteria (e.g. senders) to particular folders. I've been looking at the instructions here

https://www.virtualmin.com/documentation/tutorial/how-to-create-email-fi...

but I can't see an Email Filters link. I have Manage Folders, Address Book, Mail Preferences, Change Password, Account Information and Logout. I'll attach a screenshot.

Is this info out of date? Is there a way of setting up rules like this?

Regards Oliver Kohll

Status: 
Active

Comments

Howdy -- if you go into Webmin -> Webmin -> Usermin Configuration -> Available Modules, is the "Procmail Mail Filter" module enabled?

If not, try enabling that and see if the Manage Scripts option appears within Usermin.

If that doesn't help -- can you paste in the contents of your /etc/procmailrc file?

Hi, My Procmail Mail Filter settings look like the attached (I've tried both yes and no for 'show contents of include files'. The contents of my /etc/procmailrc are

LOGFILE=/var/log/procmail.log TRAP=/etc/webmin/virtual-server/procmail-logger.pl ORGMAIL=$HOME/Maildir/ DEFAULT=$HOME/Maildir/ DROPPRIVS=yes :0 $DEFAULT

Did you enable "Allow mailbox users to create mail filters?" under "Email Messages" -> "Spam and Virus Scanning"?

I had a similar problem in the past. By default users cannot create mail filters until you change that setting.

Thanks. I've found the main issue - I needed to turn on

Webmin -> Webmin -> Usermin configuration -> Available Modules -> Filter and forward mail

(I was using "mail forwarding and replies" previously).

I now have the filter options but a message appears at the top

"Warning - The system is configured to not process user-defined mail filters. Filters defined here will not be used."

Your last answer lp86 would seem to fix that, according to http://www.virtualmin.com/node/14004

The only thing is that I don't have any 'Spam and virus scanning' options under Email Messages. Has that option moved recently or do I need to enable another module? I don't use local spam/virus filtering. I'm happy editing config files by hand too if necessary.

Hi,

I haven't been able to find how to get round "Warning - The system is configured to not process user-defined mail filters. Filters defined here will not be used." I don't have any 'Spam and virus scanning' option under Virtualmin -> Email Messages. Is there another way to enable it? My /etc/procmailrc are above.

Oliver

It doesn't appear that your procmailrc is complete. Try setting it to the following, and see if this corrects any of the issues you are running into:

LOGFILE=/var/log/procmail.log
TRAP=/etc/webmin/virtual-server/procmail-logger.pl
:0wi
VIRTUALMIN=|/etc/webmin/virtual-server/lookup-domain.pl $LOGNAME
EXITCODE=$?
:0
* ?/usr/bin/test "$EXITCODE" = "73"
/dev/null
:0
* ?/usr/bin/test "$VIRTUALMIN" != ""
{
INCLUDERC=/etc/webmin/virtual-server/procmail/$VIRTUALMIN
}
ORGMAIL=$HOME/Maildir/
DEFAULT=$HOME/Maildir/
DROPPRIVS=yes

Thanks, however I'm now getting messages in my /var/mail.log

Feb 24 17:35:27 srv postfix/qmgr[2884]: D6D7E148E0: from=SRS0=2QqC=X5=gmail.com=oliver.kohll@emailfirewall.spamina.com, size=2362, nrcpt=1 (queue active) Feb 24 17:35:27 srv postfix/local[30080]: D6D7E148E0: to=oliver.gtwm@li349-29.members.linode.com, orig_to=oliver@agilebase.co.uk, relay=local, delay=0.09, delays=0.08/0/0/0.02, dsn=5.3.0, status=bounced (Command died with status 127: "/usr/bin/procmail-wrapper -o -a $DOMAIN -d $LOGNAME")

so I've disabled this for now. I've just checked some of those paths, they aren't on my system:

root@srv:/etc# ls -l /etc/webmin/virtual-server/lookup-domain.pl ls: cannot access /etc/webmin/virtual-server/lookup-domain.pl: No such file or directory

root@srv:/etc# ls -l /etc/webmin/virtual-server/procmail/ ls: cannot access /etc/webmin/virtual-server/procmail/: No such file or directory

however /etc/webmin/virtual-server/procmail-logger.pl is there.

Hi andreycheck, I found lookup-domain.pl in /usr/share/webmin/virtual-server/lookup-domain.pl and put this path into procmailrc, however this resulted in - mail was received ok - but senders got 'undelivered mail' bounce messages sent back to them.

Our customer is still interested in getting this working, any ideas?

Hmm, it sounds like there may be something broken regarding your server at the moment.

Is this a new installation, or has this server been online for awhile?

Also, how was the installation performed, was that using the install.sh script?

And lastly, what output does this command produce:

ls -l /usr/bin/procmail-wrapper

It's been around for quite a long time, I seem to remember the install.sh script was used but also the setup was migrated from an old server a couple of years ago.

root@srv:~# ls -l /usr/bin/procmail-wrapper -rwsr-xr-x 1 root root 2916 Nov 28 2006 /usr/bin/procmail-wrapper

That procmail-wrapper script exists, and the permissions are correct -- next step is to verify that procmail looks good. We can do that with this command:

ls -l /usr/bin/procmail

Yep, looks like that's there: root@srv:~# ls -l /usr/bin/procmail -rwsr-sr-x 1 root mail 75600 Aug 4 2010 /usr/bin/procmail

Yup, that looks correct too!

What is the output of this command:

postconf -n

Also, if you go into Webmin -> Servers -> Postfix -> Local Delivery, what is "Shell to use for delivery to external command" set to?

root@srv:~# postconf -n
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
allow_percent_hack = no
append_dot_mydomain = no
biff = no
broken_sasl_auth_clients = yes
config_directory = /etc/postfix
home_mailbox = Maildir/
inet_interfaces = all
mailbox_command = /usr/bin/procmail-wrapper -o -a $DOMAIN -d $LOGNAME
mailbox_size_limit = 0
message_size_limit = 20000000
mydestination = li349-29.members.linode.com, localhost.members.linode.com, , localhost, srv.gtwm.co.uk
myhostname = li349-29.members.linode.com
mynetworks = 127.0.0.0/8, 92.54.22.0/26, [::ffff:127.0.0.0]/104, [::1]/128
myorigin = /etc/mailname
readme_directory = no
recipient_delimiter = +
relay_domains = geraldthomas.co.uk
relay_transport = relay:[remote.geraldthomas.co.uk]
sender_bcc_maps = hash:/etc/postfix/bcc
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
smtpd_client_restrictions = permit_mynetworks reject_unauth_pipelining permit_sasl_authenticated reject
smtpd_error_sleep_time = 5s
smtpd_recipient_restrictions = permit_mynetworks permit_sasl_authenticated reject_unauth_destination
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
smtpd_soft_error_limit = 5
smtpd_tls_CAfile = /etc/postfix/CAcert.pem
smtpd_tls_cert_file = /etc/postfix/server.pem
smtpd_tls_key_file = /etc/postfix/key.pem
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtpd_use_tls = yes
virtual_alias_maps = hash:/etc/postfix/virtual

The "Shell to use for delivery to external command" is none. I attach a screenshot of all of the options in that screen.

Your Virtualmin settings look good.

Also, I've been reviewing the postconf output, and that appears to be correct as well.

There's another log file that may contain some helpful information as to what isn't working properly -- if you look at /var/log/procmail.log after attempting to send an email, what output do you see?

Aha, looks like we're getting somewhere, or at least to an error. /var/log/procmail shows

Undefined subroutine &main::get_user_domain called at /usr/share/webmin/virtual-server/lookup-domain.pl line 135.
procmail: Program failure (2) of "/usr/share/webmin/virtual-server/lookup-domain.pl"
From SRS0=UWHZ=YF=gmail.com=oliver.kohll@emailfirewall.spamina.com  Tue Mar  4 23:01:06 2014
Subject: procmail test
  Folder: /var2/home/wmoliver/Maildir/new/1393974066.20564_0.srv    2468
Time:1393974066 From:oliver.kohll@gmail.com To:oliver@agilebase.co.uk User:oliver.gtwm Size:2562 Dest:/var2/home/wmoliver/Maildir/new/1393974066.20564_0.srv Mode:None

when an email from an external source (gmail) is received.

I think the issue may be related to the lookup-domain.pl script that had been missing.

My suggestion would be to do these steps:

Delete the file /etc/webmin/virtual-server/lookup-domain.pl

Create a new test domain, with the "Spam" feature enabled

Verify that the /etc/webmin/virtual-server/lookup-domain.pl file is re-created

Once you try the above three things, try sending yourself another test email, and see if that comes through properly.

Touch wood, I think this is working! I will confirm either way once it's been running a couple of days.