Using RT with Google Apps for Domains/Education
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
- Login to Google Apps with an account that has management rights to the domain and enter into the management interface.
- Create a user to use with RT (RT or Support) might be good.
- 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 (firstname.lastname@example.org) 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.
- Click the "Save changes" button.
- 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.
- 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.
- 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.)
- Did you spell the username for the email account in Google Apps and the alias on the RT server the same?
- Did you run the "newaliases" command after modifying the /etc/aliases file?
- 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 email@example.com to firstname.lastname@example.org, and have a filter that searches for "to:email@example.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 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 AuthUserfirstname.lastname@example.org AuthPass=password FromLineOverride=YES