Configure Request Tracker (RT) to send Mails using MSMTP via Office 365 Relay

In this tutorial, we are going to learn how to configure Request Tracker (RT) to send mails using MSMTP via Office 365 Relay.  Request Tracker (RT) is an enterprise-grade issue tracking/ticketing system that allows organizations to keep track of various tasks to be done, tasks completed, and when tasks were (or weren’t) completed.

Configuring Request Tracker to send Mails using MSMTP via Office 365 Relay

Seamless Email Integration is one of the key features of Request Tracker (RT). Request Tracker receives and manages all email sent to your key email addresses: support@, sales@, helpdesk@, security@. Staff can manage ticket replies via email or by using RT’s full web interface.

MSMTP is an SMTP client which in the default mode (sendmail mode), it transmits a mail to an SMTP server which takes care of further delivery. Some of the supported features include:

  • TLS secured connections (including server certificate verification and the possibility to send a client certificate)
  • Authentication methods PLAIN, LOGIN, CRAM-MD5 and EXTERNAL (and GSSAPI, SCRAM-SHA-1, DIGEST-MD5, and NTLM when compiled with GNU SASL support)
  • Internationalized Domain Names (IDN)
  • DSN (Delivery Status Notification) support
  • PIPELINING support for increased transmission speed
  • RMQS (Remote Message Queue Starting) support (ETRN keyword)

Install Request Tracker

Before you can proceed to configure RT to send mails using MSMTP via Office 365 relay, we assume that you already have an RT installed and up and running.

If not, you can check our guide on how to install Request Tracker with MariaDB database on CentOS 8.

Install Request Tracker (RT) with MariaDB on CentOS 8

Install MSMTP on CentOS 8

In our setup, we have RT running on a CentOS 8 system. Therefore, you can simply install MSMTP SMTP client from EPEL repos by executing the commands below.

dnf install epel-release
dnf install msmtp

Configure MSMTP to Use Office 365 Mail Relay

Once the installation is done, configure MSMTP to use Office 365 Mail relay. Therefore, create an MSMTP configuration file where you can define the SMTP server host name, authentication settings, TLS settings.

Usually, this configuration file should reside within the Request Tracker configuration directory. In our setup, this directory defaults to /opt/rt4/etc.

vim /opt/rt4/etc/msmtp_wrapper.conf

Insert the following configuration options into the configuration file above.


defaults
account default
host smtp.office365.com
port 587
tls on
tls_starttls  on
tls_trust_file    /etc/pki/tls/certs/ca-bundle.crt
tls_certcheck on
auth on
user [email protected]
password r4User_pass
logfile /var/log/rt4/msmtp.log

Save and exit the file, of course, after changing the values host, the user, and password to your respective values.

Some of the options we have used above are described below;

General Options

  • defaults: set default values for all following account definitions in the current configuration file.
  • account name: Start a new account definition with the given name. In this case, default is set as the account name.
  • host hostname: defined the SMTP server to send the mail to.
  • port number: defines the port hat the SMTP server listens on. The default is 25 (“smtp”), unless TLS without STARTTLS is used, in which case it is 465 (“smtps”).

Authentication Options

  • auth on: Enables and automatically chooses authentication method to use.
  • user [email protected]: Sets the user name for authentication.
  • password r4User_pass: Sets the password for authentication user.

TLS Options

  • tls on: Enables SSL/TLS for secured connections.
  • tls_starttls on: enforces the use of TLS instead of SSL.
  • tls_trust_file /etc/pki/tls/certs/ca-bundle.crt: Activates server certificate verification using a list of trusted Certification Authorities (CAs). In this case, we use the default system CA file, ca-bundle.crt.
  • tls_certcheck on: Enable checks of the server certificate. This is enabled by default.

MSMTP sendmail mode Options

logfile: Enables logging to the specified file. An empty argument disables logging. The file name ‘’ directs the log information to standard output. In this setup, we use /var/log/rt4/msmtp.log as the log file.

Set Proper Ownership and Permissions for the MSMTP RT Configuration file

Set the user and group ownership to the user which runs RT. In this case, the user is apache.

chown apache:apache /opt/rt4/etc/msmtp_wrapper.conf

Set the following permissions on the file;

chmod 600 /opt/rt4/etc/msmtp_wrapper.conf

Create MSMTP Wrapper Script

Next, create an MSMTP wrapper script to define how to use MSMTP configuration above as well as define RT logging.

vim /opt/rt4/etc/msmtp_wrapper
#!/bin/bash
/usr/local/bin/msmtp -t -C /opt/rt4/etc/msmtp_wrapper.conf -f [email protected]
/usr/bin/logger -t RTmailer -p syslog.info -- CALL /usr/local/bin/msmtp -nt "$@" RETURNED $?

Save and exit the file.

Update the permissions and ownership of the script.

chown apache:apache /opt/rt4/etc/msmtp_wrapper
chmod +x /opt/rt4/etc/msmtp_wrapper

Verify Request Tracker MSMTP Mail Sending via Office 365 Relay

The basic setup of configuring Request Tracker (RT) to send Mails using MSMTP via Office 365 Relay is done. Before you can configure Request Tracker to actually use MSMTP, all you need to do is to verify if it can actually send mails out by executing a command like as follows;

echo "msmtp test" | msmtp --debug -t -C /opt/rt4/etc/msmtp_wrapper.conf -f [email protected] [email protected]

...
<-- 235 2.7.0 Authentication successful
--> MAIL FROM:<[email protected]>
--> RCPT TO:<[email protected]>
--> DATA
<-- 250 2.1.0 Sender OK
<-- 250 2.1.5 Recipient OK
<-- 354 Start mail input; end with <CRLF>.<CRLF>
--> From: [email protected]
--> Date: Mon, 27 Jul 2020 22:32:30 +0300
--> msmtp test
--> .
<-- 250 2.0.0 OK <AM7PR02MB61935B8DE42984C804747177D2720@AM7PR02MB6193.eurprd02.prod.outlook.com> [Hostname=AM7PR02MB6193.eurprd02.prod.outlook.com]
--> QUIT
<-- 221 2.0.0 Service closing transmission channel

At the sametime, you can tail the log as follows;

tail -f /var/log/rt4/msmtp.log
Jul 27 22:32:40 host=smtp.office365.com tls=on auth=on [email protected] [email protected] [email protected] mailsize=76 smtpstatus=250 smtpmsg='250 2.0.0 OK <AM7PR02MB61935B8DE42984C804747177D2720@AM7PR02MB6193.eurprd02.prod.outlook.com> [Hostname=AM7PR02MB6193.eurprd02.prod.outlook.com]' exitcode=EX_OK

And that seems pretty fine.

Configure Request Tracker to use MSMTP to send Mails

Once you have confirmed that MSMTP can relay mails via Office 365 SMTP servers, proceed to configure RT to use MSMTP to send emails.

Edit the line RT site config file, /opt/rt4/etc/RT_SiteConfig.pm, and replace the path on the line to Set($SendmailPath , "..."); with the path to MSMTP wrapper config file.

In our setup, we had previously configured RT to send mails using Posfix.

Set( $SendmailPath, '/usr/sbin/postfix' );

Hence, run the command below to replace it;

sed -i 's#/usr/sbin/postfix#/opt/rt4/etc/msmtp_wrapper#' /opt/rt4/etc/RT_SiteConfig.pm

This line should now looks like;

Set( $SendmailPath, '/opt/rt4/etc/msmtp_wrapper' );

Run RT site configuration syntax checks before signing off;

perl -c /opt/rt4/etc/RT_SiteConfig.pm

If all is well, you should get Syntax Ok.

/opt/rt4/etc/RT_SiteConfig.pm syntax OK

In our next tutorial, we will learn how to configure Request Tracker to retrieve mails with Fetchmail.

Reference

Msmtp – Request Tracker Wiki

Msmtp configuration options

Other Tutorials

Install and Setup Suricata on CentOS 8

Configure LibModSecurity with Apache on CentOS 8

Configure LibModSecurity with Nginx on CentOS 8

SUPPORT US VIA A VIRTUAL CUP OF COFFEE

We're passionate about sharing our knowledge and experiences with you through our blog. If you appreciate our efforts, consider buying us a virtual coffee. Your support keeps us motivated and enables us to continually improve, ensuring that we can provide you with the best content possible. Thank you for being a coffee-fueled champion of our work!

Photo of author
koromicha
I am the Co-founder of Kifarunix.com, Linux and the whole FOSS enthusiast, Linux System Admin and a Blue Teamer who loves to share technological tips and hacks with others as a way of sharing knowledge as: "In vain have you acquired knowledge if you have not imparted it to others".

Leave a Comment