Use Gmail with multiple profiles
Scenario
You have multiple profiles set up in JEMH. You want to have multiple Gmail mailboxes that receive user mail, and one main alias Gmail mailbox connected to JEMH/JIRA. When an email is sent to one of these sub-mailbox addresses, you want the corresponding JEMH profile to process that particular email and interact with the correct project of your choice. This can be done with both POP and IMAP connections.
POP
Profile Configuration
In this example, we have 3 profiles set up. ALIASTEST1, ALIASTEST2 and ALIASTEST3.
Go to each of your profiles, and then click the pen (edit) next to Email. Make sure that your catch email address is correct and pointing to the correct address. In this example, the 3 profiles are configured to catch a particular Gmail mailbox address. ALIASTEST1 is catching the test-alias1 address, ALIASTEST2 is catching the test-alias2 address, and ALIASTEST3 is catching the test-alias3 address.
Each of our example profiles has a backup project defined that is unique to that profile. If you haven't done so, now is a good time to run basic test cases to make sure your profiles are functioning properly.
Incoming Mail Configuration
We will now look at the incoming mailbox configurations in JIRA. Go to JIRA Administration>System>Incoming Mail. The first thing to do on this page is set up the POP mail server. Click "Add POP/IMAP mail server". Enter the name of the server that will be used within JIRA. Under "Service Provider" we have chosen "Google Apps Mail/Gmail (POP3)". Then add the username for the main Gmail alias mailbox address.
Gmail Important POP setting
Gmail has changed how mail is downloaded to multiple POP clients, so a little extra configuration is needed. The username (main alias mailbox address) MUST be prefixed with "recent:". In our example, this becomes "recent:testing@thepluginpeople.com".
Test your connection settings by clicking "Test Connection". If it is successful, proceed to add your incoming mail handlers. Click "Add incoming mail handler". We add a name, choose our newly created server and click "next". We now select which profile this handler is associated with, and press "Submit" to save. Repeat this process for your other profiles.
Gmail Configuration
Log in to your main alias mailbox address through the Gmail site. Go to Settings>POP/IMAP Download. Choose to enable POP for all mail. Under "When messages are accessed with POP" choose "delete <your name>'s copy". Press "Save Changes".
If all is done correctly, set-up should be complete. Test all is working by sending a test email to each of the sub-mailbox addresses. Depending on how many addresses/handlers you are dealing with, you may occasionally see messages being filtered out if you have Auditing enabled. This does not necessarily mean there is a problem - the other mail handlers may query the main mailbox and not find what they are looking for that time around.
For more information regarding Gmail POP, see here: How does Gmail POP work
For more information regarding JEMH mail auditing, see here: JEMH Auditing
IMAP
Profile Configuration
Similar to the POP set-up, we have one profile for each of the email addresses that users will send emails to. For each profile, the Catch Email Address is set to this address. In this example, we have 2 addresses; a@x.com and b@x.com.
Incoming Mail Configuration
First, lets look at the Gmail side of the configuration. The main Gmail mailbox is set to be allowed to send as our 2 sub-addresses (the ones that users will be sending emails to):
The main Gmail mailbox also has filters that label emails sent to each sub address with "A" and "B" respectively:
The sub-addresses are each set to forward the mail to the main mailbox:
Now for the JIRA incoming mail set up. We have a single mail server set up in JIRA.
We then have a mail handler set up for each of the profiles. Each mail handler is pointing to a different IMAP folder (Gmail label):