Child pages
  • improved Vexim frontend and bug fixes
Skip to end of metadata
Go to start of metadata

Overview

Virtual exim (vexim) is a nice PHP frontend for the Exim4 mail transport agent. Using vexim it is easy to add or modify email accounts and virus and spam settings.

Vexim's homepage already has a few patches and modifications, however I found a few bugs and they were not nicely integrated into the PHP frontend. So I tried to fix them and integrate my favorite patches into one file.

The major improvements over the existing release are:

  • Spam emails can be moved or deleted based on user's preferences
  • The Subject line of spam emails can be marked, again based on user's preferences
  • The PHP user interface has been cleaned up a bit
  • German translation brushed up, missing strings added

Screenshot of the new Vexim GUI

Download

This modification is based on vexim2.2RC1 .

vexim2.2RC1-schirmacher.tar.gz

This tar file is pretty much identical with what I have currently installed on live systems. Some path names, user IDs etc. are different from what is in the vexim2.2RC1.tar.gz file.

vexim2.2RC1-schirmacher.patch

This is a patch file to be applied on the contents of vexim2.2RC1.tar.gz file. It does not contain any locally modified path names, user IDs etc. but it is not tested. To apply the patch, executed the commands below:

v0000:/tmp# tar xfz vexim2.2RC1.tar.gz
v0000:/tmp# cd vexim2
v0000:/tmp/vexim2# patch -p1 < ../vexim2.2RC1-schirmacher.patch
patching file docs/configure
patching file vexim/adminuseradd.php
patching file vexim/adminuserchange.php
patching file vexim/adminuserchangesubmit.php
patching file vexim/locale/de_DE/LC_MESSAGES/de.po
patching file vexim/sitechange.php
patching file vexim/style.css
patching file vexim/userchange.php
patching file vexim/userchangesubmit.php
patching file docs/vexim-acl-check-content.conf
patching file docs/vexim-acl-check-rcpt.conf
patching file docs/rewrite_subject.pl
v0000:/tmp/vexim2#

Installation

Use the Virtual Vexim installation manual (http://silverwraith.com/vexim/readme.php), or this DebianHowto Page (in german language).

If you are modifying an existing vexim installation instead of installing from scratch, you need to manually create two new database fields:

mysql vexim
> alter table users  ADD on_rewritesubject bool NOT NULL  default '0';
> alter table users  ADD movedelete bool NOT NULL  default '0';

The file docs/rewrite_subject.pl must be copied into /etc/exim4 and it must be made executeable. The perl script requires the Mail::Internet perl package, which is not available on some systems. Run the perl script from the command line. If there is an error install the missing perl package (libmailtools-perl on Debian).

# cp docs/rewrite_subject.pl /etc/exim4
# chmod 755 /etc/exim4/rewrite_subject.pl
#  perl /etc/exim4/rewrite_subject.pl
Can't locate Mail/Internet.pm in @INC ....

Note that the german localization file is not included because it is a binary file. Either recreate it with

msgfmt -v locale/de_DE/LC_MESSAGES/de.po -o locale/de_DE/LC_MESSAGES/messages.mo

or copy this file from the archive above.

Documentation

I have started a german Vexim handbook. It currently contains only the user part, not the administrator part.

Known Bugs

If you find a bug in this vexim modification, I want to hear about it and fix it.

Please contact: Arne Schirmacher .

Activating forwarding turns off email subject rewriting

The "forward email" and "rewrite email subject" can't be used at the same time. The rewrite email subject code is never executed.

Blacklists don't work

The blacklisting feature does not work, because the ACL rules actually do not retrieve the blacklisting information from MySQL. 

Changelog

Filtering Spam

Based on: http://veximwiki.silverwraith.com/index.php/Filtering_Spam_New

This patch moves all spam into a separate folder. I am using the folder name "Junk" instead of "Spam", because also Thunderbird uses this folder name and both SpamAssassin filtered and Thunderbird filtered emails will end up in the same directory.

The user can choose whether to move spam into this folder, to delete it right away or to deliver it in the standard way.

Rewriting Subject of Spam

Inspired by: http://veximwiki.silverwraith.com/index.php/Marking_Subject_of_SPAM

... but the patch has bugs. It sort of works, but not as intended. The author wanted to rewrite the subject of the spam email according to user settings, but at execution time the variables $local_part and $domain are undefined and the whole clause fails. However, the Subject line is rewritten whenever the SpamAssassin spam ratings exceeds the defaults (instead of the user defined values). So if the user has entered the same rating as SpamAssassin's default (5) it looks as if it actually works but it does not.

The correct time for rewriting the Subject line is at transport time. This will also make sure that each user can user their own subject rewriting preferences. The original patch modified the Subject line for every user.

Greylisting

While you are configuring vexim, you may want to check out this new article on greylisting:

SPAM filtern mit Greylisting 

New german language translation 

I went through all of the german text to make it a bit more consistent and added the required strings for the new features. Some strings in the PHP code lacked the internationalization function, which were added. This will also benefit other translations.

Credits

Thanks to Avleen Vig for creating Virtual Exim. Several other individuals have also contributed:

http://silverwraith.com/vexim/credits.html

Statistics

This page has been viewed

Unknown macro: {content-info} zero

times.

42 Comments

  1. Anonymous

    Hi,

    thanks for your changes. I have applied your patch and have patched the config files. The options are now in vexim but none of the work. Must I create a junk folder myself? Also the option enable spamassissn doesn't work. Do you have an idea what goes wrong?

     Greetings Hannes

    1. did you restart exim and did you add the new database fields to the MySQL DB?

      Please run exim in debug mode:

      /usr/sbin/exim4 -bd -q30m -d
      

      If anything goes wrong then the log file should give some hints what the problem could be.

  2. Anonymous

    Many thanks for your work. I spent a lot of time trying to make the marking of spam possible with the original howto.. Now with your modification all works great.

    I just have one question. When activating mail forwarding the subject is not changed at all (for spam mails). So is this function working for local storage only?

    Greeting Tobias

    1. yes, this is definitively a bug. I have just found out myself after turning on the mail forwarding and getting tons of spam email after returning from the business trip. Will add this to the Known Bugs section.

  3. Anonymous

    Debian users have to install "libmailtools-perl" ( Mail::Internet ) to get the rewrite_subject.pl script running!

    Greetings Raphael 

  4. Anonymous

    Great work, thanx for this !

    I use your .tar and I am happy with it (wink)

    But i don't get the localization running (sad)

    So what do i have to do for... let's say german interface ?

    The

     /www/vexim/locale/de_DE/LC_MESSAGES/de.po
    /www/vexim/locale/de_DE/LC_MESSAGES/messages.po

    are there, and the i18n.php

    says "$language = 'de_DE';"

    So what do i have to do ?

    Greetinx 

    1. Please try with the unmodified vexim release to see whether it is an issue with this patch or with your system setup.

      This is difficult to answer. Is your Linux server set up for german locale? I had the same problem and I had to install some locale related Debian packages.

      1. Anonymous

        Hello Arne,

        do you remember which packages? I have the same problem, but I don't know which packages are necessary.

        Kind regards

        infu. 

  5. Anonymous

    Hi,

    tnx for your great work.

    Did you know about the status of the blacklisting functionality ? MySQL Tabels excist.

     Best ReMa

    1. Doesn't the blacklisting functionality work for you? I have never actually tested it as vexim uses the sbl and xbl blacklists from http://www.spamhaus.org (plus a handful other blacklists), which already block at least 75% of all incoming spam emails.

      Let me know if it does not work. If so, it is however a vexim problem and not related to this patch as I did not modify any of the related vexim code.

      1. Anonymous

        no, i mean, blackling / whitelisting by adding IP's in the mysql-tables.

        Best ReMa

        1. As I am now using Greylisting (see SPAM filtern mit Greylisting), it would be very useful if greylistd's blacklisting/whitelisting features could be set via the vexim pages.

          If I only had more time....

  6. Anonymous

    I've got your improved vexim frontend runnung for some weeks and I'm really happy with it.

    One thing I noticed was that when I enabled email forwarding (including keeping a local copy):
    Marked spam emails were also forwarded and were also not moved to the spam folder as before but were delivered in the inbox.

    Commenting out

     and users.on_forward = '0' \

    in the condition clause of the " ditch_spam_movetojunk" filter changed this behaviour to the one I expected it to be: Spam mails are not forwarded and are delivered in the junkmail folder.

     
    Just as a note for other users.

     
    Greets, Nils

  7. Anonymous

    If I add a new user, I can't set the spam filtering details and even if the spam filter is activated spam mails will be delivered to the mail account. After you have created an account you can go to the account details and specify what exim should do with spam.

    1. The default behaviour is to do nothing with the spam (that is, deliver it into the mailbox). That's just how it is. The "Create user" dialog does not have all the options the "Modify user" dialog has. So you need this extra step to actually turn on spam filtering.

      But I agree, it would be very useful if one at least has the "Mark  spam" or "Move spam" options available in the "Create user" dialog, or if domain defaults can be set for this option.

  8. Anonymous

    It works now for a couple of months.

     I have only one problem: The old subject line ist not removed, so I have to subject lines in the mailheader.
    One with original subject and another subject: *SPAM* .... Now it depends on the mail program which subject is displayed.

     How can I remove the old subject line?

    Greetings Hannes

    1. The rewriting of the subject line is handled in /etc/exim4/rewrite_subject.pl. Please check whether this file is actually called, and if it is called, why it does not run as expected. It is only 12 lines of code, should be trivial to debug.

      If it is not called, run exim in debug mode: stop the exim daemon, then run /usr/sbin/exim4 -d -bd -q30m. The rewrite_subject.pl code is supposed to be execute somewhere in the virtual_delivery section.

  9. Anonymous

    Hi,

    thank You for Your excellent work! I have a problem with the function forward with local copy. The forwarding works fine - there are no errors in exim4 logfiles - but there is no local copy in my maildir. Have You any suggestion for me where I can search for mistakes?

    Greetings Basti 

    1. Anonymous

      Hi, again Basti here(smile)

      I want to specify my problem: I started exim in debug mode; the log output for "forward mode" and "forward with local copy mode" are absolut identically, there is no attempt for local saving. Whats wrong?

      Thank You, grettings basti 

      1. Anonymous

        Hi, and again Basti here,

        my problem is solved - sorry - I forgot to update the exim configuration file. Now all works fine, Thank You! 

        1. great, I was just about to post my response -- everythink works here....

  10. Anonymous

    Hi Arne,

    I have tried to do a new setup with your improvements and everything seems to work fine, except one big thing: I can access vexim as the siteadmin and as the postmaster. However, if I try to login as a user or try to edit a normal user from within the postmaster account I get an error like this:

    Parse error: parse error, unexpected $ in /srv/www/ssldocs/vexim2/userchange.php on line 155

    or

    Parse error: parse error, unexpected $ in /srv/www/ssldocs/vexim2/adminuserchange.php on line 214

    respectively.

    Any ideas what could have caused this? Btw, for each of the files, the number of lines they actually have is one lower than the count mentioned...

    Thanks,

    Martin

    1. I can't reproduce this. What Apache version, PHP version, OS and Webbrowser are you using? Please compare the checksums of the files:

      $ cksum adminuserchange.php userchange.php
      63453405 11652 adminuserchange.php
      401978531 7646 userchange.php
      
      1. Anonymous

        Hi Arne,

        I use Apache 2.0.54, PHP 4.3.10-18 with Zend Optimizer V3.0.2. I use Internet Explorer 7.

        I will test with different browsers and compare the checksum for the files.

        Thanks,

        Martin

        1. Anonymous

          Oh, and the server runs on Debian Sarge 3.1. The OS for accessing is Windows XP SP2.

          Martin

    2. Anonymous

      Its that crap with using <?php and <? - you have to choices: Clean up the codebase or changing you php.ini to allow short open tags.

  11. Anonymous

    Hi!
    Thanks for the great patch!
    Do I have to mkdir the "Junk"-folder or is it create automaticly?

  12. Anonymous

    Nice small DB-Frontend. But the code is more or less crap! Uninitialized variables grabbed directly from environment and the switch between <?php and <? may cause pain in admins head and it is a sign that vexim is still a dirty hack than an thrustable tool.

    So please:

    1. Ensure that all variables are properly initialized and sanitized
    2. Avoid hopping between <?php and <? - use <?php instead because it is more common

    Thanks! 

    1. That is very true. However, the new vexim release 2.2.1is cleaned up, the source code does not look as messy as the previous version, on which my patch is based.

      I am working on migrating my changes to the official release, as time permits.

  13. Anonymous

    That was a great patch (thanks a lot!), but now all the accounts were the spam header rewriting is enabled once (and actually if you remove that option it doesn't make sense), every message has been rewrited with that "***SPAM(0.0)**"-style. Is this right?

     I googled and found that somebody else has the same patch, but can anybody made a solution for that problem? I guess that the subject is rewrited only then, if the "mark as spam" (= the smaller number of these twos) has been reached, but...it rewrite the every message's subject. (sad)

    I'm running the VExim2.2.1 and manually make the "patch" (by following the patc's diff's..) if it make sense to the problem..

    1. The Spam Header Rewriting is a bit involved (it looks suboptimal but there seems no other way to do it). First, for every email a new mail header line is inserted into the email. This new mail header line is "X-New-Subject". This is done in vexim-acl-check-content.conf.

      Second, if the spam value is less than what the user has entered as his limit this line is removed again from the email header. This is done in the file exim4.conf, search for "headers_remove".

      Finally, for all emails that still have the "X-New-Subject" line it is renamed into "Subject". This is done with rewrite_subject.pl which is called from exim4.conf in the transports. 

      So my guess is that in step 2 the "X-New-Subject" line is never removed. Please run exim4 in debug mode (see the article how to do this), then check why the MySQL Query fails. 

  14. Anonymous

    Thanks for help, I research twice all the configuration files and run exim in debug mode but didn't find the problem. Until...once again exim4.conf and find a reference to: system_filter = /etc/vexim/vexim-systemfilter ... I can't remember where that came, but now this patch works great.

  15. Anonymous

    Hello Arne,

    you said you are working on porting your patch to 2.2.1.
    Can you tell me when it will be released ?

    Although, I was planing on using Mailscanner together with my setup.
    Do you know if that is going to work with exim4 + vexim ?

  16. Anonymous

    Hi Arne,

    I wanted to port your changes to 2.2.1 but I noticed that a whole lot changed in 2.2.1 and it's not that easy for me as I'm not into vexim2 and stuff. I wish you good luck though to migrate your changes to 2.2.1. Any chance to see them upstream?

  17. Anonymous

    Hallo Arne!

    Wann denkst Du denn ungefähr wann mit einem Release für 2.2.1 zu rechnen ist?

    Gruss

    -Frank-

  18. Anonymous

    Hallo, tolle Arbeit. Ich hatte ziemlich Probleme das Rewritedes Subject hinzubkommen. Ich habs nun Systemweit so gelöst (vexim-acl-check-content.conf):

    # Always add X-Spam-Score and X-Spam-Report headers, using SA system-wide settings
      # (user "spamd"), no matter if over threshold or not.
      warn  message         = X-Spam-Score: $spam_score ($spam_bar)
            spam            = spamd:true
      warn  message         = X-Spam-Report: $spam_report
            spam            = spamd:true
      warn  message         = Subject: [SPAM] $h_Subject
            spam            = spamd:true

      accept hosts          = 127.0.0.1:+relay_from_hosts
      accept authenticated  = *

    Gruesse Markus 

  19. Anonymous

    Hi,

    Anhand des Patchfiles hab ich meine eigene Installation gepatcht, vielen Dank dafür.

    Funktioniert alles wunderbar, aber ich habe bei mir noch ein paar sachen geändert die vllt. für den Patch auch interessant wären:

    Mich hat gestört das ausgehende Emails bei der vexim installation ja auch gescannt werden (jedenfalls sehe ich keine möglichkeit das zuverhindern) also habe das remote_smtp statement folgend abgeändert:

    remote_smtp:
      headers_remove = X-Spam-Score:X-Spam-Report:X-New-Subject
      driver = smtp

    Dadurch werden die X-Spam header bei ausgehenden Emails entfernt.

    Auch enthalten die Emails danach immer noch den X-New-Subject header. Diesen hab ich also im ditch_spam_transport am ende folgendes Statement hinzugefügt:

     headers_remove = X-New-Subject

    1. Anonymous

      Geht doch viel einfacher. Einfach die Content-ACL editieren und das "! authenticated = *" dazusetzen:

      warn ! authenticated = *
      message = X-Spam-Score: $spam_score ($spam_bar)
      condition = ${if <{$message_size}

      Unknown macro: {150k}
      Unknown macro: {1}

      {0}}
      spam = vmail:true

      warn ! authenticated = *
      message = X-Spam-Report: $spam_report
      condition = ${if <{$message_size}

      Unknown macro: {1}

      {0}}
      spam = vmail:true

      1. Anonymous

        Urks. Hier nochmal:

        warn ! authenticated = *
        message = X-Spam-Score: $spam_score ($spam_bar)
        condition = ${if <{$message_size}{150k}{1}{0}}
        spam = vmail:true

        warn ! authenticated = *
        message = X-Spam-Report: $spam_report
        condition = ${if <{$message_size}{150k}{1}{0}}
        spam = vmail:true

  20. Anonymous

    Hi alle zusammen,

    habe mir Exim4 und VExim 2.2.2RC1 (von googlecode) installiert.

    Läuft auch alles recht gut.

    Meine Frage wäre, ob man den von Arne angebotenen Patch da drüber laufen lassen kann?

    Kann man in Vexim / Spamassassin eigentlihc einstellen, daß jede Email gefiltert werden soll?

    Manche Provider macht er nämlcih nicht (bei mir z.B. gmx).

    1. Der Patch ist sicher nicht mit der neuen Version kompatibel. Die einen oder anderen Bugfixes oder Verbesserungen sind sicher auch in VExim 2.2 drin.

      Wieso Spamassassin keine Emails von gmx filtert, ist mir nicht klar, vielleicht verstehe ich die Frage auch nicht.