In this tutorial, you will learn how to configure Request Tracker to fetch email requests from mail box. Any support request is sent to a mail box such as [email protected]. In order for the application to display/show these requests on its web dashboard, you need to configure it to be able to fetch the mails sent to the support mail box.
Configure Request Tracker to Fetch Email Requests from Mail Box
There are different applications you can configure Request tracker to use to fetch email requests from the mail box. These include fetchmail, mbox2rt and pop3mailgate. We will however be using fetchmail in this guide.
Configure RT to Fetch Mails using Fetchmail
To begin with, install fetchmail program on your Request Tracker server.
Ubuntu/Debian and Similar derivative;
apt install fetchmail
CentOS/Rocky/Oracle/RHEL based derivatives;
yum install fetchmail
Consult respective Linux distro documentation on how to install fetchmail.
Once the installation is done, you need to configure fetchmail to retrive email from a mail box.
Thus, create a configuration file for fetchmail, /etc/fetchmailrc
Here is our sample configuration. Note that we are using Gmail as our mail server. Hence, make appropriate changes.
set daemon 60 set no syslog set logfile "/var/log/fetchmail/fetchmail.log" set no bouncemail defaults: antispam -1 batchlimit 100 poll imap.gmail.com protocol IMAP user "[email protected]" password "passW)RD" ssl no fetchall no rewrite keep mda "/opt/rt5/bin/rt-mailgate --url https://rt5.itnixpro.com --no-verify-ssl --queue General --action correspond --debug"
Below are the Fetchmail keywords/options summary.
|Set a background poll interval in seconds.
|Give the name of the last-resort mail recipient (default: user running fetchmail, “postmaster” if run by the root user)
|Direct error mail to the sender (default)
|set no bouncemail
|Direct error mail to the local postmaster (as per the ‘postmaster’ global option above).
|set no spambounce
|Do not bounce spam-blocked mail (default).
|Bounce blocked spam-blocked mail (as per the ‘antispam’ user option) back to the destination as indicated by the ‘bouncemail’ global option. Warning: Do not use this to bounce spam back to the sender – most spam is sent with false sender address and thus this option hurts innocent bystanders.
|set no softbounce
|Delete permanently undeliverable mail. It is recommended to use this option if the configuration has been thoroughly tested.
|Keep permanently undeliverable mail as though a temporary error had occurred (default).
|Name of a file to append error and status messages to. Only effective in daemon mode and if fetchmail detaches. If effective, overrides set syslog.
|Name of the PID file.
|Name of the file to store UID lists in.
|Do error logging through syslog(3). May be overridden by set logfile.
|set no syslog
|Turn off error logging through syslog(3). (default)
|String value that is ignored by fetchmail (may be used by extension scripts).
Here are the legal server options:
|Specify DNS name of mail server, overriding poll name
|Specify protocol (case insensitive): POP2, POP3, IMAP, APOP, KPOP
|Specify domain(s) to be regarded as local
|Specify TCP/IP service port (obsolete, use ‘service’ instead).
|Specify service name (a numeric value is also allowed and considered a TCP/IP port number).
|Set authentication type (default ‘any’)
|Server inactivity timeout in seconds (default 300)
|Specify envelope-address header name
|Disable looking for envelope address
|Qmail virtual domain prefix to remove from user name
|Specify alternate DNS names of mail server
|specify IP interface(s) that must be up for server poll to take place
|Specify IP address to monitor for activity
|Specify command through which to make server connections.
|Specify command through which to make listener connections.
|Enable DNS lookup for multidrop (default)
|Disable DNS lookup for multidrop
|Do comparison by IP address for multidrop
|Do comparison by name for multidrop (default)
|Force POP3 to use client-side UIDLs (recommended)
|Turn off POP3 use of client-side UIDLs (default)
|Only check this site every N poll cycles; N is a numeric argument.
|Add poll tracing information to the Received header
|Set Kerberos principal (only useful with IMAP and kerberos)
|Set name for RFC2554 authentication to the ESMTP server.
|Set password for RFC2554 authentication to the ESMTP server.
|How to treat messages with a bad header. Can be reject (default) or accept.
Here are the legal user descriptions and options:
|This is the user description and must come first after server description and after possible server options, and before user options.It sets the remote user name if by itself or followed by ‘there’, or the local user name if followed by ‘here’.
|Connect local and remote user names
|Connect local and remote user names
|Specify remote account password
|Connect to server over the specified base protocol using SSL encryption
|Specify file for client side public SSL certificate
|Enable strict certificate checking and abort connection on failure. Default only since fetchmail v6.4.0.
|Disable strict certificate checking and permit connections to continue on failed verification. Discouraged. Should only be used together with sslfingerprint.
|Specify file with trusted CA certificates
|Specify c_rehash-ed directory with trusted CA certificates.
|Specify the expected server certificate finger print from an MD5 hash. Fetchmail will disconnect and log an error if it does not match.
|Specify file for client side private SSL key
|Force ssl protocol for connection
|Specify remote folder to query
|Specify smtp host(s) to forward to
|Specify domains for which mail should be fetched
|Specify the domain to be put in RCPT TO lines
|Specify the user and domain to be put in RCPT TO lines
|Specify what SMTP returns are interpreted as spam-policy blocks
|Specify MDA for local delivery
|Specify BSMTP batch file to append to
|Command to be executed before each connection
|Command to be executed after each connection
|Do not delete seen messages from server (for POP3, uidl is recommended)
|Flush all seen messages before querying (DANGEROUS)
|Flush all oversized messages before querying
|Fetch all messages whether seen or not
|Rewrite destination addresses for reply (default)
|Strip carriage returns from ends of lines
|Force carriage returns at ends of lines
|Force BODY=8BITMIME to ESMTP listener
|Strip Status and X -Mozilla-Status lines out of incoming mail
|Strip Delivered-To lines out of incoming mail
|Convert q uoted-printable to 8-bit in MIME messages
|Idle waiting for new messages after each poll (IMAP only)
|Delete seen messages from server (default)
|Do not flush all seen messages before querying (default)
|Retrieve only new messages (default)
|Do not rewrite headers
|Do not strip carriage returns (default)
|Do not force carriage returns at EOL (default)
|Do not force BODY=8BITMIME to ESMTP listener (default)
|Do not drop Status headers (default)
|Do not drop Delivered-To headers (default)
|Do not convert q uoted-printable to 8-bit in MIME messages (default)
|Do not idle waiting for new messages after each poll (IMAP only)
|Set message size limit
|Set message size warning interval
|Max # messages to forward in single connect
|Max # messages to fetch in single connect
|Max # message sizes to fetch in single transaction
|Use binary search for first unseen message (POP3 only)
|Perform an expunge on every #th message (IMAP and POP3 only)
|String value is ignored by fetchmail (may be used by extension scripts)
Update the permissions and ownership of the fetchmailrc configuration file;
chmod 0600 /etc/fetchmailrc
chown fetchmail: /etc/fetchmailrc
Create the log file directory specified for the Fetchmail by the
set logfile "/var/log/fetchmail/fetchmail.log";
Next, create the log file;
Set the ownership to fetchmail;
chown -R fetchmail: /var/log/fetchmail
Ensure the log file is rotated;
sed -i '/messages/a /var/log/fetchmail/fetchmail.log' /etc/logrotate.d/rsyslog
Running Fetchmail Service as Daemon
We will run Fetchmail as a systemd service in this setup.
Thus, edit the defaults configuration file and enable it to run as daemon;
Similarly, enable some verbosity to help in troubleshooting;
Save and exit the file.
Start Fetchmail service;
systemctl enable --now fetchmail
Check the logs;
tail -f /var/log/fetchmail/fetchmail.log
When a user who has rights to create a ticket on RT sends an email to RT support email address, it should now be able to be displayed on the Request tracker web user interface under the default queue, General, as specified by the mda command in the fetchmailrc configuration file.
fetchmail: IMAP< A0007 OK Success fetchmail: message [email protected]@imap.gmail.com:2 was not the expected length (4751 actual != 5102 expected) /opt/rt5/bin/rt-mailgate: temp file is '/tmp/1WC_sA3hkF/SG1bWJ28nd' /opt/rt5/bin/rt-mailgate: connecting to http://rt5.itnixpro.com/REST/1.0/NoAuth/mail-gateway ok Ticket: 5 Queue: General Owner: Nobody Status: new Subject: Fetchmail Ticket Confirmation Requestor: [email protected] fetchmail: not flushed fetchmail: IMAP> A0008 STORE 2 +FLAGS (\Seen) fetchmail: IMAP< * 2 FETCH (FLAGS (\Seen)) fetchmail: IMAP< A0008 OK Success fetchmail: selecting or re-polling default folder fetchmail: 0 messages waiting after re-poll fetchmail: IMAP> A0009 LOGOUT fetchmail: IMAP< * BYE LOGOUT Requested fetchmail: IMAP< A0009 OK 73 good day (Success) fetchmail: 6.4.2 querying imap.gmail.com (protocol IMAP) at Mon Oct 3 21:07:18 2022: poll completed fetchmail: New UID list from imap.gmail.com:
fetchmail: not swapping UID lists, no UIDs seen this query fetchmail: sleeping at Mon Oct 3 21:07:18 2022 for 60 seconds
Similarly, tail RT logs just in case there is an issue;
tail -f /var/log/rt5/rt5.itnixpro.com.log
And that concludes our guide on how to configure Request Tracker to fetch email requests from mail box.