Jira incoming mail handler processes the email using an incorrect user

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform Notice: Server and Data Center Only. This article only applies to Atlassian products on the server and data center platforms.

Problem

When a user sends an email to the incoming mail handler, the email is either not processed or is processed using an incorrect user.

If the emails are not processed, warnings informing that the user is lacking application access can be observed in the atlassian-jira-incoming-mail.log files, even though within the UI the user does have application access.

2019-01-01 20:00:00,000 WARN [Jira Mailhandler] Caesium-1-4 anonymous    Jira Mailhandler Jira Mailhandler[10001]: Cannot create issue due to invalid license: [Sorry, you can't create any issues right now, as you need to have access to a Jira application to be able to create issues. To gain application access you need to be a member of a group assigned to an application.]

Cause

When multiple users with the same email address exist in the Jira database, Jira will use the first username that matches the email address.

For example:

The instance has the following users in the database.

IDDIRECTORY_IDACTIVELOWER_USER_NAMELOWER_EMAIL_ADDRESS
5010catlassiancharlie.atlassian@mail.com
68100011charlie.atlassiancharlie.atlassian@mail.com

In this scenario, directory 10001 is the topmost directory.

In the Jira UI, the user catlassian will be disabled and does not have application access. However, if an email is received by charlie.atlassian@mail.com, the application will select the user catlassian to create an issue or comment as this user has a lower ID and is thus queried prior to the correct user. This will result in the following error:

2019-01-01 20:00:00,000 WARN [Jira Mailhandler] Caesium-1-4 anonymous    Jira Mailhandler Jira Mailhandler[10001]: Cannot create issue due to invalid license: [Sorry, you can't create any issues right now, as you need to have access to a Jira application to be able to create issues. To gain application access you need to be a member of a group assigned to an application.]

Diagnosis

This behavior can be verified by querying the database for the email address. For example, for the email address charlie.atlassian@mail.com:

SELECT id, directory_id, active, lower_user_name, lower_email_address FROM cwd_user WHERE lower_email_address = 'charlie.atlassian@mail.com';

Output:

IDDIRECTORY_IDACTIVELOWER_USER_NAMELOWER_EMAIL_ADDRESS
5010catlassiancharlie.atlassian@mail.com
68100011charlie.atlassiancharlie.atlassian@mail.com

Workaround

There are two workarounds for this issue;

  1. Align the username between the two directories.
  2. If the first option is not possible, modify the email address of the incorrect user so that it no longer matches an existing user.
UPDATE cwd_user SET email_address = 'inactive@localhost', lower_email_address = 'inactive@localhost' WHERE lower_email_address = 'charlie.atlassian@mail.com' AND id = '50';


Always back up your data before performing any modifications to the database. If possible, test any alter, insert, update, or delete SQL commands on a staging server first.

Description

duplicate email addresses cause conflict with the incoming mail handler. Based on JRASERVER-28485

Product
Jira, Jira, Jira Service Management
Last modified on Nov 23, 2020

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.