GoogleApps

From Request Tracker Wiki
Revision as of 16:11, 6 April 2016 by Admin (talk | contribs) (4 revisions imported)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Using RT with Google Apps for Domains/Education

Receiving Mail

Option 1: Have Google route email to your server

  • This article assumes you have a working RT3 install that is fully configured (minus the Google Apps and rt-mailgate bits of course), has a working domain name and public IP (or is accessible from the internet), and has a working MTA (Postfix, Sendmail, etc.) on it.
  • Setting up the Google Apps Account
    1. Login to Google Apps with an account that has management rights to the domain and enter into the management interface.
    2. Create a user to use with RT (RT or Support) might be good.
    3. After the user is created go into its properties and scroll down to the "Email Routing" section and click the "Add another destination" link then enter the account you want it sent to at your server (support@rtserver.yourdomain.com) and make sure both check boxes are checked (Not sure if the "Change SMTP Envelope is needed but that is how I have it setup). You may also want to uncheck the box next to "Google Apps Email" if you don't want/need email to be collected in the Gmail inbox.
    4. Click the "Save changes" button.
  • Setting up the mail handling on your RT server
    1. Create a local user on the RT server with the same username as the email address you created (support is what I used so I created a user named "support" on my RT server). If you don't do this your mail will be undeliverable. Virtual users are beyond the scope of this article.
    2. Edit /etc/aliases with your favorite editor and add the entries for the user that you created in Google Apps (mine was support, this is the part before the @ in the email address). It should look like this: support: "|/opt/rt3/bin/rt-mailgate --queue general --action correspond --url http://localhost/" Note: The /opt/rt3/bin/rt-mailgate should be modified to point to where ever you put your rt-mailgate. Add any other aliases you need and then save the file.
    3. run the "newaliases" command to update the aliases database. (I also restarted postfix for good measure, so you may want to do restart your MTA.)
  • Troubleshooting
    1. Did you spell the username for the email account in Google Apps and the alias on the RT server the same?
    2. Did you run the "newaliases" command after modifying the /etc/aliases file?
    3. Did you double-check that the email routing setting was saved?

Option 2: Use fetchmail

  • An alternative that doesn't require configuring an incoming mail server is to simply use fetchmail to poll your Google Apps email account(s) and use fetchmail's MDA option to dump the messages directly into rt-mailgate.
  • Your Google email account can be set up to use aliases and filters to sort messages into RT Queues. For example, alias idea@your.com to rt@your.com, and have a filter that searches for "to:idea@your.com" and tags it with an "Idea" label. Gmail "labels" serve as IMAP "folders" which fetchmail can keep separate. The example below relies on two such folders to dump messages into different queues. This is useful mostly because Google charges some users per user for hosted apps, but aliases are free.
  • Set up fetchmail to poll your Google accounts. This is most easily done on a *nix based server, with a regular user, using a .fetchmailrc file similar to this one:

set daemon 300
set logfile /home/YOUR-USER/fm.log
poll YOUR-APPS-DOMAIN.com via imap.gmail.com with proto IMAP
    user 'rt@YOUR-APPS-DOMAIN.com' there with password 'YOUR-PASSWORD' is YOUR-USER here mda "/usr/bin/rt-mailgate --queue Support --action correspond --url http://YOUR-RT-URL/rt"
      options ssl sslcertck sslcertpath /YOUR/CERT/PATH folder Support
poll YOUR-APPS-DOMAIN.com via imap.gmail.com with proto IMAP
    user 'rt@YOUR-APPS-DOMAIN.com' there with password 'YOUR-PASSWORD' is YOUR-USER here mda "/usr/bin/rt-mailgate --queue Ideas --action correspond --url http://YOUR-RT-URL/rt"
      options ssl sslcertck sslcertpath /YOUR/CERT/PATH folder Ideas

  • You should also set up a cron job under your user to make sure the daemon gets restarted after reboots. Simply running fetchmail is sufficient, because fetchmail will only let one daemon instance per user run at a time anyway.
  • After making sure things work, you should remove the logfile line or it will grow endlessly as you get messages.

Sending Mail

Sending mail with Google Apps is most easily accomplished with ssmtp. This is a basic package that can be found for practically any distribution. In Debian/Ubuntu, the setup and configuration are straightforward. This works with either method of receiving the mail detailed above.

Keep in mind that ssmtp doesn't queue, so if RT tries to send mail and fails to connect to smtp.gmail.com your mail will be lost. Any normal MTA can be configured to do SASL auth over SSL and accomplish the same thing while queueing your mail.


# apt-get install ssmtp
# nano /etc/ssmtp/ssmtp.conf
UseTLS=YES
UseSTARTTLS=YES
mailhub=smtp.gmail.com:587
AuthMethod=LOGIN
AuthUser=rt@example.com
AuthPass=password
FromLineOverride=YES