I am trying to use the 'Kernel::System::PostMaster::Filter::CMD' module to filter an incoming email so when the email is not found in my customer database it puts the email in the Junk folder

 

Below is what I have inserted in my config.pm right after my server settings.  My understanding is the script simply has to return a 0 or a 1 if a 1 is returned it will move the email into the Junk folder, can someone look over my syntax I have in my config?  I know my script works, and returns a 1 when an email is found, but maybe my config syntax is wrong or in the script should I be exiting or returning 1?  Meaning should I end with exit 1;   or   return 1;?  Any help would greatly be appreciated.

 

Rob

 

Snipet from Config.pm:

 

# Job Name: 5-noEmailFoundFilter

 

        $Self->{'PostMaster::PreFilterModule'}->{'9- noEmailFoundFilter'} = {

 

                Module => 'Kernel::System::PostMaster::Filter::CMD',

 

                CMD => '/opt/otrs/scripts/mysqlscript',

 

 

                Set => {

 

                        'X-OTRS-Queue' => 'Junk',

 

                },

 

        };

 

 

Here is my script:

 

 

sender_mail=`awk '/^(From.*<)(.*)(>*)/,gsub(/.*<|>.*/,"")'`

 

 

retcode=1

 

 

sql=`mysql -N -B -u otrs -potrs otrs -e "select login from customer_user where email = \"$sender_mail\""`

 

if [ $sender_mail != $sql ]; then

       retcode=1

else

       retcode=0

 

fi

 

echo "this script has run $sender_mail and $sql and retcode = $retcode" > /tmp/mysqlscript.pid$$

exit $retcode