Via command line programm and e. g. procmail

OTRS is able to receive emails via a command line programm (bin/PostMaster.pl).

That means emails will be shown in your OTRS system if the MDA (mail delivery agent, e. g. procmail) pipes the emails into bin/PostMaster.pl.

To test the bin/PostMaster.pl on your command line (without MDA) use:
shell:~ # cat /opt/otrs/doc/test-email-1.box | /opt/otrs/bin/PostMaster.pl
shell:~ #
If the email is shown in the QueueView then your setup works fine.

Procmail is a very common e-mail filter in the Linux enviroment. It will be probably installed on your system. If not have a look at the procmail homepage.

To configure procmail for that (requires a procmail configured MTA (e. g. sendmail, postfix, exim or qmail)) use the ~otrs/.procmailrc and modify/add the following.
SYS_HOME=$HOME
PATH=/bin:/usr/bin:/usr/local/bin
# --
# Pipe all email into the PostMaster process.
# --
:0 :
| $SYS_HOME/bin/PostMaster.pl
All emails sent to the local otrs user will be piped into bin/PostMaster.pl and then shown in your QueueView.

Queue dispatching with OTRS

OTRS is able to dispatch incoming emails via "To" address. Configurable via admin interface.

Example

Add a new system email address (AdminArea -->> System Email Addresses).

In this case, all incoming emails (with To: support@company.com) will be dispatched to the TEST1 queue.

Queue dispatching with procmail (for more complex dispatching)

The X-OTRS-Queue Mail-Header

The X-OTRS-Queue Mail-Header is parsed by OTRS and OTRS will pipe these e-mails direct in this queue. Procmail and fromail can be used to create a powerfull dispatcher tool.

Examples

The following examples are copied from the procmailex man-page. Feel free to have a look into it (actually it is quite a good idea). Of course we changed the wording a bit (to fit it into the queueing idea).

Sort out all mail coming from the scuba-dive mailing list into the scuba queue.
:0 fhw :
* ^TOscuba
| formail -I "X-OTRS-Queue: scuba"
Forward all mail from peter about compilers into the william queue.
:0 fhw :
* ^From.*peter
* ^Subject:.*compilers
| formail -I "X-OTRS-Queue: william"
And here a last example, the whole .procmailrc.

Example 5-1. .procmailrc

# --
# .procmailrc - procmailrc of the OTRS user
# Copyright (C) 2001-2002 Martin Edenhofer (martin+code at otrs.org)
# --
# $Id: receiving_email.sgml,v 1.2 2003/01/18 12:30:46 stefan Exp $
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see 
# the enclosed file COPYING for license information (GPL). If you 
# did not receive this file, see http://www.gnu.org/licenses/gpl.txt.
# --

SYS_HOME=$HOME

PATH=/bin:/usr/bin:/usr/local/bin
MONTHFOLDER=`date +%Y-%m`
YEARFOLDER=`date +%Y`
LOGFILE=$SYS_HOME/var/log/procmail-$MONTHFOLDER.log
VERBOSE=on

# --
# Remove all X-OTRS Header (allow this only for trusted email)
# e. g. from *@example.com
# --
:0 fhw :
* !^From.*@example.com
| grep -vi '^X-OTRS-'

# --
# Examples for queue presorting.
# --

:0 fhw :
* ^List-Id:.*OpenAntiVirus
| formail -I "X-OTRS-Queue: OpenAntiVirus"

:0 fhw :
* ^Sender:.*example.com
| formail -I "X-OTRS-Queue: example"

:0 fhw :
* TO:.*BUGTRAQ
| formail -I "X-OTRS-Queue: BUGTRAQ"

# --
# Backup of all incoming emails. 
# It's always better to have a backup of all incoming emails!
# --
:0 c :
$SYS_HOME/var/INBOX.Backup.$MONTHFOLDER

# --
# Pipe all email into the PostMaster process.
# --
:0 :
| $SYS_HOME/bin/PostMaster.pl

# --
# spool all the rest (which the PostMaster.pl can't process!) 
# If the database is down or the PostMaster.pl exit was not '0'!
# --
:0 :
$SYS_HOME/var/spool/.

# --
# end of .procmailrc
# --
Please have a look into the procmailex man-page for more examples.

Example with procmail and a webform

This is an example for a webform to generate an email for OTRS. You will find this perl scrtipt in $OTRS_HOME/scripts/webform.pl

You have a Topic, From, Email, Subject and Message field.

Change the config settings for the webform:
# --
# web form options
# -- 
my $Ident = 'ahfiw2Fw32r230dddl2foeo3r';
# sendmail location and options
my $Sendmail = '/usr/sbin/sendmail -t -i -f ';
# email where the emails of the form will send to
my $OTRSEmail = 'otrs-system@example.com';
# topics and dest. queues
my %Topics = (
    # topic => OTRS queue
    'Info' => 'info',
    'Support' => 'support',
    'Bugs' => 'bugs',
    'Sales' => 'sales',
    'Billing' => 'billing',
    'Webmaster' => 'webmaster',
);
Take care, that your used $OTRSEmail and the used OTRS queues exists in your OTRS system.

Now, change the OTRS .procmailrc from:
# --
# Remove all X-OTRS Header (allow this only for trusted email)
# e. g. from *@example.com
# --
:0 fhw :
* !^From.*@example.com
| grep -vi '^X-OTRS-'
to:
# --
# Remove all X-OTRS Header (allow this only for trusted email)
# just not emails with "X-OTRS-Ident: ahfiw2Fw32r230dddl2foeo3r" header!
# --
:0 fhw :
* !^X-OTRS-Ident: ahfiw2Fw32r230dddl2foeo3r
| grep -vi '^X-OTRS-'
If a email is generated by the webform.pl and sent to the $OTRSEmail it will be dispatched to the topic=>queue.

Fetching emails via POP3 or IMAP and fetchmail

In order to get e-mails from your mail server via a POP3 or IMAP mailbox to the OTRS machine/local otrs account and to procmail use fetchmail. Note: A working SMTP configuration on the OTRS machine is condition.

Example 5-2. .fetchmailrc

#poll (mailserver) protocol POP3 user (user) password (password) is (localuser)
poll mail.example.com protocol POP3 user joe password mama is otrs

Don't forget to set the .fetchmailrc to 710 ("chmod 710 .fetchmailrc")!

So if "fetchmail -a" is executed (maybe via cron), all e-mails will be forwarded to the local otrs account.