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
vim /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.
Keyword | Opt | Mode | Function |
---|---|---|---|
set daemon | -d | Set a background poll interval in seconds. | |
set postmaster | Give the name of the last-resort mail recipient (default: user running fetchmail, “postmaster” if run by the root user) | ||
set bouncemail | 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). | ||
set spambounce | 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. | ||
set softbounce | Keep permanently undeliverable mail as though a temporary error had occurred (default). | ||
set logfile | -L | 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. | |
set pidfile | -p | Name of the PID file. | |
set idfile | -i | Name of the file to store UID lists in. | |
set syslog | Do error logging through syslog(3). May be overridden by set logfile. | ||
set no syslog | Turn off error logging through syslog(3). (default) | ||
set properties | String value that is ignored by fetchmail (may be used by extension scripts). |
Here are the legal server options:
Keyword | Opt | Mode | Function |
---|---|---|---|
via | Specify DNS name of mail server, overriding poll name | ||
proto[col] | -p | Specify protocol (case insensitive): POP2, POP3, IMAP, APOP, KPOP | |
local[domains] | m | Specify domain(s) to be regarded as local | |
port | Specify TCP/IP service port (obsolete, use ‘service’ instead). | ||
service | -P | Specify service name (a numeric value is also allowed and considered a TCP/IP port number). | |
auth[enticate] | Set authentication type (default ‘any’) | ||
timeout | -t | Server inactivity timeout in seconds (default 300) | |
envelope | -E | m | Specify envelope-address header name |
no envelope | m | Disable looking for envelope address | |
qvirtual | -Q | m | Qmail virtual domain prefix to remove from user name |
aka | m | Specify alternate DNS names of mail server | |
interface | -I | specify IP interface(s) that must be up for server poll to take place | |
monitor | -M | Specify IP address to monitor for activity | |
plugin | Specify command through which to make server connections. | ||
plugout | Specify command through which to make listener connections. | ||
dns | m | Enable DNS lookup for multidrop (default) | |
no dns | m | Disable DNS lookup for multidrop | |
checkalias | m | Do comparison by IP address for multidrop | |
no checkalias | m | Do comparison by name for multidrop (default) | |
uidl | -U | Force POP3 to use client-side UIDLs (recommended) | |
no uidl | Turn off POP3 use of client-side UIDLs (default) | ||
interval | Only check this site every N poll cycles; N is a numeric argument. | ||
tracepolls | Add poll tracing information to the Received header | ||
principal | Set Kerberos principal (only useful with IMAP and kerberos) | ||
esmtpname | Set name for RFC2554 authentication to the ESMTP server. | ||
esmtppassword | Set password for RFC2554 authentication to the ESMTP server. | ||
bad-header | How to treat messages with a bad header. Can be reject (default) or accept. |
Here are the legal user descriptions and options:
Keyword | Opt | Mode | Function |
---|---|---|---|
user[name] | -u | 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’. | |
is | Connect local and remote user names | ||
to | Connect local and remote user names | ||
pass[word] | Specify remote account password | ||
ssl | Connect to server over the specified base protocol using SSL encryption | ||
sslcert | Specify file for client side public SSL certificate | ||
sslcertck | Enable strict certificate checking and abort connection on failure. Default only since fetchmail v6.4.0. | ||
no sslcertck | Disable strict certificate checking and permit connections to continue on failed verification. Discouraged. Should only be used together with sslfingerprint. | ||
sslcertfile | Specify file with trusted CA certificates | ||
sslcertpath | Specify c_rehash-ed directory with trusted CA certificates. | ||
sslfingerprint | <HASH> | Specify the expected server certificate finger print from an MD5 hash. Fetchmail will disconnect and log an error if it does not match. | |
sslkey | Specify file for client side private SSL key | ||
sslproto | Force ssl protocol for connection | ||
folder | -r | Specify remote folder to query | |
smtphost | -S | Specify smtp host(s) to forward to | |
fetchdomains | m | Specify domains for which mail should be fetched | |
smtpaddress | -D | Specify the domain to be put in RCPT TO lines | |
smtpname | Specify the user and domain to be put in RCPT TO lines | ||
antispam | -Z | Specify what SMTP returns are interpreted as spam-policy blocks | |
mda | -m | Specify MDA for local delivery | |
bsmtp | Specify BSMTP batch file to append to | ||
preconnect | Command to be executed before each connection | ||
postconnect | Command to be executed after each connection | ||
keep | -k | Do not delete seen messages from server (for POP3, uidl is recommended) | |
flush | -F | Flush all seen messages before querying (DANGEROUS) | |
limitflush | Flush all oversized messages before querying | ||
fetchall | -a | Fetch all messages whether seen or not | |
rewrite | Rewrite destination addresses for reply (default) | ||
stripcr | Strip carriage returns from ends of lines | ||
forcecr | Force carriage returns at ends of lines | ||
pass8bits | Force BODY=8BITMIME to ESMTP listener | ||
dropstatus | Strip Status and X -Mozilla-Status lines out of incoming mail | ||
dropdelivered | Strip Delivered-To lines out of incoming mail | ||
mimedecode | Convert q uoted-printable to 8-bit in MIME messages | ||
idle | Idle waiting for new messages after each poll (IMAP only) | ||
no keep | -K | Delete seen messages from server (default) | |
no flush | Do not flush all seen messages before querying (default) | ||
no fetchall | Retrieve only new messages (default) | ||
no rewrite | Do not rewrite headers | ||
no stripcr | Do not strip carriage returns (default) | ||
no forcecr | Do not force carriage returns at EOL (default) | ||
no pass8bits | Do not force BODY=8BITMIME to ESMTP listener (default) | ||
no dropstatus | Do not drop Status headers (default) | ||
no dropdelivered | Do not drop Delivered-To headers (default) | ||
no mimedecode | Do not convert q uoted-printable to 8-bit in MIME messages (default) | ||
no idle | Do not idle waiting for new messages after each poll (IMAP only) | ||
limit | -l | Set message size limit | |
warnings | -w | Set message size warning interval | |
batchlimit | -b | Max # messages to forward in single connect | |
fetchlimit | -B | Max # messages to fetch in single connect | |
fetchsizelimit | Max # message sizes to fetch in single transaction | ||
fastuidl | Use binary search for first unseen message (POP3 only) | ||
expunge | -e | Perform an expunge on every #th message (IMAP and POP3 only) | |
properties | 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"
;
mkdir /var/log/fetchmail
Next, create the log file;
touch /var/log/fetchmail/fetchmail.log
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;
vim /etc/default/fetchmail
START_DAEMON=yes
Similarly, enable some verbosity to help in troubleshooting;
OPTIONS="-vv"
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.