{"id":6525,"date":"2020-07-27T23:19:44","date_gmt":"2020-07-27T20:19:44","guid":{"rendered":"https:\/\/kifarunix.com\/?p=6525"},"modified":"2024-03-14T22:06:11","modified_gmt":"2024-03-14T19:06:11","slug":"configure-request-tracker-rt-to-send-mails-using-msmtp-via-office-365-relay","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/configure-request-tracker-rt-to-send-mails-using-msmtp-via-office-365-relay\/","title":{"rendered":"Configure Request Tracker (RT) to send Mails using MSMTP via Office 365 Relay"},"content":{"rendered":"\n<p>In this tutorial, we are going to learn how to configure Request Tracker (RT) to send mails using MSMTP via Office 365 Relay. &nbsp;<a href=\"https:\/\/bestpractical.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">Request Tracker (RT)<\/a>&nbsp;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\u2019t) completed.<\/p>\n\n\n\n<div class=\"wp-block-rank-math-toc-block\" id=\"rank-math-toc\"><h2>Table of Contents<\/h2><nav><ul><li><a href=\"#configuring-request-tracker-to-send-mails-using-msmtp-via-office-365-relay\">Configuring Request Tracker to send Mails using MSMTP via Office 365 Relay<\/a><ul><li><a href=\"#install-request-tracker\">Install Request Tracker<\/a><\/li><li><a href=\"#install-msmtp-on-cent-os-8\">Install MSMTP on CentOS 8<\/a><\/li><li><a href=\"#configure-msmtp-to-use-office-365-mail-relay\">Configure MSMTP to Use Office 365 Mail Relay<\/a><ul><li><a href=\"#general-options\">General Options<\/a><\/li><li><a href=\"#authentication-options\">Authentication Options<\/a><\/li><li><a href=\"#tls-options\">TLS Options<\/a><\/li><li><a href=\"#msmtp-sendmail-mode-options\">MSMTP sendmail mode Options<\/a><\/li><\/ul><\/li><li><a href=\"#set-proper-ownership-and-permissions-for-the-msmtp-rt-configuration-file\">Set Proper Ownership and Permissions for the MSMTP RT Configuration file<\/a><\/li><li><a href=\"#create-msmtp-wrapper-script\">Create MSMTP Wrapper Script<\/a><\/li><li><a href=\"#verify-request-tracker-msmtp-mail-sending-via-office-365-relay\">Verify Request Tracker MSMTP Mail Sending via Office 365 Relay<\/a><\/li><li><a href=\"#configure-request-tracker-to-use-msmtp-to-send-mails\">Configure Request Tracker to use MSMTP to send Mails<\/a><\/li><li><a href=\"#reference\">Reference<\/a><\/li><li><a href=\"#other-tutorials\">Other Tutorials<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"configuring-request-tracker-to-send-mails-using-msmtp-via-office-365-relay\">Configuring Request Tracker to send Mails using MSMTP via Office 365 Relay<\/h2>\n\n\n\n<p>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\u2019s full web interface.<\/p>\n\n\n\n<p><a aria-label=\"undefined (opens in a new tab)\" href=\"https:\/\/marlam.de\/msmtp\/\" target=\"_blank\" rel=\"noreferrer noopener\">MSMTP<\/a> is an SMTP client which in the default mode (<code>sendmail mode<\/code>), it transmits a mail to an SMTP server which takes care of further delivery. Some of the supported features include:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>TLS secured connections (including server certificate verification and the possibility to send a client certificate)<\/li>\n\n\n\n<li>Authentication methods PLAIN, LOGIN, CRAM-MD5 and EXTERNAL (and GSSAPI, SCRAM-SHA-1, DIGEST-MD5, and NTLM when compiled with GNU SASL support)<\/li>\n\n\n\n<li>Internationalized Domain Names (IDN)<\/li>\n\n\n\n<li>DSN (Delivery Status Notification) support<\/li>\n\n\n\n<li>PIPELINING support for increased transmission speed<\/li>\n\n\n\n<li>RMQS (Remote Message Queue Starting) support (ETRN keyword)<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"install-request-tracker\">Install Request Tracker<\/h3>\n\n\n\n<p>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.<\/p>\n\n\n\n<p>If not, you can check our guide on how to install Request Tracker with MariaDB database on CentOS 8.<\/p>\n\n\n\n<p><a aria-label=\"undefined (opens in a new tab)\" href=\"https:\/\/kifarunix.com\/install-request-tracker-rt-with-mariadb-on-centos-8\/\" target=\"_blank\" rel=\"noreferrer noopener\">Install Request Tracker (RT) with MariaDB on CentOS 8<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"install-msmtp-on-cent-os-8\"><a href=\"#install-msmtp-on-centos-8\">Install MSMTP on CentOS 8<\/a><\/h3>\n\n\n\n<p>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.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>dnf install epel-release<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>dnf install msmtp<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"configure-msmtp-to-use-office-365-mail-relay\"><a href=\"#configure-msmtp-on-centos-8\">Configure MSMTP to Use Office 365 Mail Relay<\/a><\/h3>\n\n\n\n<p>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.<\/p>\n\n\n\n<p>Usually, this configuration file should reside within the Request Tracker configuration directory. In our setup, this directory defaults to <code><strong>\/opt\/rt4\/etc<\/strong><\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>vim \/opt\/rt4\/etc\/msmtp_wrapper.conf<\/code><\/pre>\n\n\n\n<p>Insert the following configuration options into the configuration file above.<\/p>\n\n\n\n<pre class=\"scroll-box\"><code>\ndefaults\naccount default\nhost smtp.office365.com\nport 587\ntls on\ntls_starttls  on\ntls_trust_file    \/etc\/pki\/tls\/certs\/ca-bundle.crt\ntls_certcheck on\nauth on\nuser r4@kifarunix-demo.com\npassword r4User_pass\nlogfile \/var\/log\/rt4\/msmtp.log\n<\/code><\/pre>\n\n\n\n<p>Save and exit the file, <strong>of course<\/strong>, after changing the values host, the user, and password to your respective values.<\/p>\n\n\n\n<p>Some of the options we have used above are described below;<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"general-options\">General Options<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><code>defaults<\/code><\/strong>: set default values for all following account definitions in the current configuration file.<\/li>\n\n\n\n<li><code><strong>account <em>name<\/em><\/strong><\/code>: Start a new account definition with the given <em>name<\/em>. In this case, default is set as the account name.<\/li>\n\n\n\n<li><code><strong>host<em> hostname<\/em><\/strong><\/code>: defined the SMTP server to send the mail to.<\/li>\n\n\n\n<li><strong><code>port&nbsp;<var>number<\/var>:<\/code><\/strong> defines the port hat the SMTP server listens on. The default is 25 (&#8220;smtp&#8221;), unless TLS without STARTTLS is used, in which case it is 465 (&#8220;smtps&#8221;).<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"authentication-options\">Authentication Options<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><code>auth <em>on<\/em><\/code><\/strong>: Enables and automatically chooses authentication method to use.<\/li>\n\n\n\n<li><strong><code>user <em>r4@kifarunix-demo.com<\/em><\/code><\/strong>: Sets the user name for authentication.<\/li>\n\n\n\n<li><strong><code>password <em>r4User_pass<\/em><\/code><\/strong>: Sets the password for authentication user.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"tls-options\">TLS Options<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code><strong>tls <em>on<\/em><\/strong><\/code>: Enables SSL\/TLS for secured connections.<\/li>\n\n\n\n<li><code><strong>tls_starttls  <em>on<\/em><\/strong><\/code>:  enforces the use of TLS instead of SSL.<\/li>\n\n\n\n<li><code><strong>tls_trust_file    <em>\/etc\/pki\/tls\/certs\/ca-bundle.crt<\/em><\/strong><\/code>: Activates server certificate verification using a list of trusted Certification Authorities (CAs). In this case, we use the default system CA file, <em><strong>ca-bundle.crt<\/strong><\/em>.<\/li>\n\n\n\n<li><strong><em><code>tls_certcheck on<\/code><\/em><\/strong>: Enable checks of the server certificate. This is enabled by default.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"msmtp-sendmail-mode-options\">MSMTP sendmail mode Options<\/h4>\n\n\n\n<p><strong><code>logfile<\/code><\/strong>: Enables logging to the specified file. An empty argument disables logging. The file name \u2018<samp>&#8211;<\/samp>\u2019 directs the log information to standard output. In this setup, we use <code><strong>\/var\/log\/rt4\/msmtp.log<\/strong><\/code> as the log file.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"set-proper-ownership-and-permissions-for-the-msmtp-rt-configuration-file\">Set Proper Ownership and Permissions for the MSMTP RT Configuration file<\/h3>\n\n\n\n<p>Set the user and group ownership to the user which runs RT. In this case, the user is <strong><code>apache<\/code><\/strong>.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>chown apache:apache \/opt\/rt4\/etc\/msmtp_wrapper.conf<\/code><\/pre>\n\n\n\n<p>Set the following permissions on the file;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>chmod 600 \/opt\/rt4\/etc\/msmtp_wrapper.conf<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"create-msmtp-wrapper-script\">Create MSMTP Wrapper Script<\/h3>\n\n\n\n<p>Next, create an MSMTP wrapper script to define how to use MSMTP configuration above as well as define RT logging.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>vim \/opt\/rt4\/etc\/msmtp_wrapper<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>#!\/bin\/bash\n\/usr\/local\/bin\/msmtp -t -C \/opt\/rt4\/etc\/msmtp_wrapper.conf -f r4@kifarunix-demo.com\n\/usr\/bin\/logger -t RTmailer -p syslog.info -- CALL \/usr\/local\/bin\/msmtp -nt \"$@\" RETURNED $?<\/code><\/pre>\n\n\n\n<p>Save and exit the file.<\/p>\n\n\n\n<p>Update the permissions and ownership of the script.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>chown apache:apache \/opt\/rt4\/etc\/msmtp_wrapper<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>chmod +x \/opt\/rt4\/etc\/msmtp_wrapper<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"verify-request-tracker-msmtp-mail-sending-via-office-365-relay\">Verify Request Tracker MSMTP Mail Sending via Office 365 Relay<\/h3>\n\n\n\n<p>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;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>echo \"msmtp test\" | msmtp --debug -t -C \/opt\/rt4\/etc\/msmtp_wrapper.conf -f r4@kifarunix-demo.com admin@kifarunix-demo.com<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>\n...\n&lt;-- 235 2.7.0 Authentication successful\n--&gt; MAIL FROM:&lt;r4@kifarunix-demo.com&gt;\n--&gt; RCPT TO:&lt;admin@kifarunix-demo.com&gt;\n--&gt; DATA\n&lt;-- 250 2.1.0 Sender OK\n&lt;-- 250 2.1.5 Recipient OK\n&lt;-- 354 Start mail input; end with &lt;CRLF&gt;.&lt;CRLF&gt;\n--&gt; From: r4@kifarunix-demo.com\n--&gt; Date: Mon, 27 Jul 2020 22:32:30 +0300\n--&gt; msmtp test\n--&gt; .\n&lt;-- 250 2.0.0 OK &lt;AM7PR02MB61935B8DE42984C804747177D2720@AM7PR02MB6193.eurprd02.prod.outlook.com&gt; [Hostname=AM7PR02MB6193.eurprd02.prod.outlook.com]\n--&gt; QUIT\n&lt;-- 221 2.0.0 Service closing transmission channel\n<\/code><\/pre>\n\n\n\n<p>At the sametime, you can tail the log as follows;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>tail -f \/var\/log\/rt4\/msmtp.log<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>Jul 27 22:32:40 host=smtp.office365.com tls=on auth=on user=r4@kifarunix-demo.com from=r4@kifarunix-demo.com recipients=admin@kifarunix-demo.com mailsize=76 smtpstatus=250 smtpmsg='250 2.0.0 OK &lt;AM7PR02MB61935B8DE42984C804747177D2720@AM7PR02MB6193.eurprd02.prod.outlook.com&gt; &#91;Hostname=AM7PR02MB6193.eurprd02.prod.outlook.com]' exitcode=EX_OK<\/code><\/pre>\n\n\n\n<p>And that seems pretty fine.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"configure-request-tracker-to-use-msmtp-to-send-mails\">Configure Request Tracker to use MSMTP to send Mails<\/h3>\n\n\n\n<p>Once you have confirmed that MSMTP can relay mails via Office 365 SMTP servers, proceed to configure RT to use MSMTP to send emails.<\/p>\n\n\n\n<p>Edit the line RT site config file, <strong><code>\/opt\/rt4\/etc\/RT_SiteConfig.pm<\/code><\/strong>, and replace the path on the line to <code><strong>Set($SendmailPath , \"...\");<\/strong><\/code> with the path to MSMTP wrapper config file.<\/p>\n\n\n\n<p>In our setup, we had previously configured RT to send mails using Posfix.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>Set( $SendmailPath, '\/usr\/sbin\/postfix' );<\/code><\/pre>\n\n\n\n<p>Hence, run the command below to replace it;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sed -i 's#\/usr\/sbin\/postfix#\/opt\/rt4\/etc\/msmtp_wrapper#' \/opt\/rt4\/etc\/RT_SiteConfig.pm<\/code><\/pre>\n\n\n\n<p>This line should now looks like;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>Set( $SendmailPath, '\/opt\/rt4\/etc\/msmtp_wrapper' );<\/code><\/pre>\n\n\n\n<p>Run RT site configuration syntax checks before signing off;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>perl -c \/opt\/rt4\/etc\/RT_SiteConfig.pm<\/code><\/pre>\n\n\n\n<p>If all is well, you should get <strong>Syntax Ok<\/strong>.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>\/opt\/rt4\/etc\/RT_SiteConfig.pm<strong> syntax OK<\/strong><\/code><\/pre>\n\n\n\n<p>In our next tutorial, we will learn how to configure Request Tracker to retrieve mails with Fetchmail.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"reference\">Reference<\/h3>\n\n\n\n<p><a aria-label=\"undefined (opens in a new tab)\" href=\"https:\/\/rt-wiki.bestpractical.com\/wiki\/Msmtp#Install_msmtp\" target=\"_blank\" rel=\"noreferrer noopener\">Msmtp &#8211; Request Tracker Wiki<\/a><\/p>\n\n\n\n<p><a aria-label=\"undefined (opens in a new tab)\" href=\"https:\/\/marlam.de\/msmtp\/msmtp.html#Configuration-files\" target=\"_blank\" rel=\"noreferrer noopener\">Msmtp configuration options<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"other-tutorials\">Other Tutorials<\/h3>\n\n\n\n<p><a aria-label=\"undefined (opens in a new tab)\" href=\"https:\/\/kifarunix.com\/install-and-setup-suricata-on-centos-8\/\" target=\"_blank\" rel=\"noreferrer noopener\">Install and Setup Suricata on CentOS 8<\/a><\/p>\n\n\n\n<p><a aria-label=\"undefined (opens in a new tab)\" href=\"https:\/\/kifarunix.com\/configure-libmodsecurity-with-apache-on-centos-8\/\" target=\"_blank\" rel=\"noreferrer noopener\">Configure LibModSecurity with Apache on CentOS 8<\/a><\/p>\n\n\n\n<p><a aria-label=\"undefined (opens in a new tab)\" href=\"https:\/\/kifarunix.com\/configure-libmodsecurity-with-nginx-on-centos-8\/\" target=\"_blank\" rel=\"noreferrer noopener\">Configure LibModSecurity with Nginx on CentOS 8<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, we are going to learn how to configure Request Tracker (RT) to send mails using MSMTP via Office 365 Relay. &nbsp;Request Tracker<\/p>\n","protected":false},"author":1,"featured_media":14253,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[121,272,1323,1322],"tags":[1142,1841,1840,1843,1842,1844,1325],"class_list":["post-6525","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-howtos","category-email","category-request-tracker-rt","category-ticketing-systems","tag-centos-8","tag-configure-msmtp-for-request-tracker-rt","tag-install-msmtp-on-centos-8","tag-msmtp-office-365-mail-relay","tag-msmtp-request-tracker","tag-office-365-smtp","tag-request-tracker","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50","resize-featured-image"],"_links":{"self":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/6525"}],"collection":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/comments?post=6525"}],"version-history":[{"count":5,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/6525\/revisions"}],"predecessor-version":[{"id":21443,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/6525\/revisions\/21443"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media\/14253"}],"wp:attachment":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media?parent=6525"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/categories?post=6525"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/tags?post=6525"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}