# Logstash input imap plugin with attachment not decoding

**URL:** <https://discuss.elastic.co/t/logstash-input-imap-plugin-with-attachment-not-decoding/323113>\
**Category:** Logstash\
**Created:** [January 13, 2023, 9:58am UTC](https://discuss.elastic.co/t/logstash-input-imap-plugin-with-attachment-not-decoding/323113 "2023-01-13T09:58:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![anjuls](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anjuls/32/115901_2.png) [@anjuls](https://discuss.elastic.co/u/anjuls)\
**Post date:** [January 13, 2023, 9:58am UTC](https://discuss.elastic.co/t/logstash-input-imap-plugin-with-attachment-not-decoding/323113/1 "2023-01-13T09:58:03Z")

</div>

Hi,

I am trying to fetch emails with attachments from Office 365 using logstash and putting them on Kafka topic. During the process, I got to understand the logstash-imap-input plugin is unable to process it. When the attachment such as image is inline in the email, then I receive a kafka message with data encoded as base64.

```auto

input {
  imap {
    host => "outlook.office365.com"
    user => " *****"
    password => " ****"
    secure => true
    folder => "INBOX"
    check_interval => 60 # Specified in seconds
    fetch_count => 10
    save_attachments => true
    attachments_target => "attachment"
    headers_target => "headers"
    # strip_attachments => true
    content_type => "multipart/mixed"
  } 
}

output {
  kafka {
    codec => json
    topic_id => "email"
    compression_type => gzip
    value_serializer => "org.apache.kafka.common.serialization.ByteArraySerializer"

  }
}

```

Error msg:

```auto

[2023-01-13T15:24:03,087][ERROR][logstash.inputs.imap][main][e29e62f1aee00e8c941cda3e54fc2c243d202fc7e24fb6edf819b64232b1da6c] Encountered error NoMethodError {:message=>"Can not decode an entire message, try calling #decoded on the various fields and body or parts if it is a multipart message.", :backtrace=>["/Users/anjul/Documents/Projects/ ***/logstash-8.6.0/vendor/bundle/jruby/2.6.0/gems/mail-2.6.6/lib/mail/message.rb:1903:in `decoded'", "/Users/anjul/Documents/Projects/**** /logstash-8.6.0/vendor/bundle/jruby/2.6.0/gems/logstash-input-imap-3.2.0/lib/logstash/inputs/imap.rb:220:in `parse_mail'",

```

Let me know if you have any solution for this problem?

Thanks  
Anjul

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 10, 2023, 9:58am UTC](https://discuss.elastic.co/t/logstash-input-imap-plugin-with-attachment-not-decoding/323113/2 "2023-02-10T09:58:55Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
