Content
[INCOMING-EMAIL] Email attachments are discarded and an error is logged...
Added by Thomas Goodman 13 days ago
Hi,
Goal: Send any email to a mailbox read by Openproject to automatically create a work package and assign it to a user and keep attachments (if any).
Issue: If there is one or more attachments in the email, then an error is logged, the work package is still created but it has no files (attachments). Whereas if there is no attachment to the email then the work package is created fine w/o any error (good!).
Error: Message X resulted in error undefined local variable or method 'sender_email' for an instance of IncomingEmails::Handlers::WorkPackage undefined local variable or method 'sender_email' for an instance of IncomingEmails::Handlers::WorkPackage (see Failure logs below for context).
Expectations: An email with attachment should translate to a new Task in the work packages and if attachments are present they should be found in the Files section of the new task. As explained here.
Environment
-
Debian 13
-
Docker
-
Openproject 16.3.2 / 16.6.1 (latest)
-
IMAP server imap.purelymail.com with mailbox foobar@domain.xyz
-
./docker/prod/cron is a mounted volume for debugging purpose to add
--traceto the script but I am unsure if it does display anything extra. -
Email sent via Thunderbird in plain text or HTML with or without attachments.
-
Email should become Tasks in the demo-project's work packages
Failure logs
```
cron-1 | [cron] Rescheduling in 30s
cron-1 | [cron] Checking for new emails from IMAP
cron-1 | bundle exec rake redmine:email:receive_imap host='imap.purelymail.com' username='foobar@domain.xyz' password='<REDACTED>' ssl='true' ssl_verification='true' port='993' folder='' project='demo-project' category='' priority='' status='' version='' type='Task' assigned_to='john.wick' unknown_user='accept' no_permission_check='1' move_on_success='INBOX.success' move_on_failure='INBOX.failure' allow_override='' --trace || true
cron-1 | ** Invoke redmine:email:receive_imap (first_time)
cron-1 | ** Invoke environment (first_time)
cron-1 | ** Execute environment
cron-1 | /app/vendor/bundle/ruby/3.4.0/gems/grape-2.3.0/lib/grape/util/registry.rb:10:in 'Grape::Util::Registry#register': json is already registered with class Bim::Bcf::API::ErrorFormatter::Json (StructuredWarnings::StandardWarning)
cron-1 | ** Execute redmine:email:receive_imap
cron-1 | I, [2025-12-02T04:24:08.373705 #39557] INFO -- : [ActiveJob] Enqueued Notifications::WorkflowJob (Job ID: 006808a4-4a44-4752-8029-6667afb50b69) to GoodJob(default)
cron-1 | I, [2025-12-02T04:24:08.388421 #39557] INFO -- : [ActiveJob] Enqueued Journals::CompletedJob (Job ID: 6bf6c672-b8dd-46fd-81d5-dae39d014e9c) to GoodJob(default) at 2025-12-02 04:29:08 UTC
cron-1 | I, [2025-12-02T04:24:08.499746 #39557] INFO -- : [ActiveJob] Enqueued Notifications::WorkflowJob (Job ID: 02966cab-c174-4834-bbfe-8f0bdfecc1e6) to GoodJob(default)
cron-1 | I, [2025-12-02T04:24:08.506370 #39557] INFO -- : [ActiveJob] Enqueued Journals::CompletedJob (Job ID: d6872224-4211-4a5f-8273-11a6babd6a45) to GoodJob(default) at 2025-12-02 04:29:08 UTC
cron-1 | E, [2025-12-02T04:24:08.727660 #39557] ERROR -- : Message 2 resulted in error undefined local variable or method 'sender_email' for an instance of IncomingEmails::Handlers::WorkPackage undefined local variable or method 'sender_email' for an instance of IncomingEmails::Handlers::WorkPackage
cron-1 | [cron] Rescheduling in 30s
```
Note: The ruby warning about the json class is recurrent too whether there is an email or not.
Config
```
IMAP_HOST: "imap.purelymail.com"
IMAP_PORT: 993
IMAP_USERNAME: "foobar@domain.xyz"
IMAP_PASSWORD: "<REDACTED>"
IMAP_CHECK_INTERVAL: 30
# See: https://www.openproject.org/docs/installation-and-operations/configuration/incoming-emails/#sending-user-address
IMAP_UNKNOWN_USER: accept
IMAP_NO_PERMISSION_CHECK: 1
# Set default location and attrs
IMAP_ATTR_PROJECT: "demo-project"
IMAP_ATTR_TYPE: "Task"
IMAP_ATTR_ASSIGNED_TO: "john.wick"
IMAP_MOVE_ON_SUCCESS: "INBOX.success"
IMAP_MOVE_ON_FAILURE: "INBOX.failure"
```
Questions:
-
Am I missing an attribute or did I misconfigure something? in regards to 'undefined local variable' ?
-
Why does it fail with attachment only but works for any other email?
Any hints to make the email attachments work as expected are appreciated.
Replies (2)
Also I do not intend to drive Openproject work packages by using any attributes within the email to set anything. I simply would like any email, whether plain or HTML to create a Task in a specific project.
Should I create a bug instead?