# Logstash email image problem

**URL:** <https://discuss.elastic.co/t/logstash-email-image-problem/373713>\
**Category:** Logstash\
**Created:** [January 27, 2025, 10:55am UTC](https://discuss.elastic.co/t/logstash-email-image-problem/373713 "2025-01-27T10:55:57Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hannah\_J\_Swystun](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hannah_j_swystun/32/139547_2.png) [@Hannah\_J\_Swystun](https://discuss.elastic.co/u/Hannah_J_Swystun)\
**Post date:** [January 27, 2025, 10:55am UTC](https://discuss.elastic.co/t/logstash-email-image-problem/373713/1 "2025-01-27T10:55:57Z")

</div>

Hi everybody,

i try to send email from logstash version 7.8.0 but, images are never shown!  
however attachments are added to email and can be opened!  
i used different kind of images, none of them work ?  
can someone help please

```auto
ruby {
  code => "

html_table += '<img src=\"/tmp/files/images/na.png\" />'

html_table += '<img src=\"https://picsum.photos/536/354\" />'

html_table += '<img src=\"data:image/jpeg;charset=utf-8;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg== \" />'

    event.set('html_test', html_table)
  "
  }

output {
  email {
    address => ""
    port => 587
    via => "smtp"
    username => ""
    password => ""
    use_tls => true
    authentication => "login"
    from => ""
    to => ""
    subject => ""
    htmlbody => "%{html_test}"
    contenttype => "text/html; charset=UTF-8"
    attachments => ["/tmp/files/images/na.png", "/tmp/files/images/passed.png", "/tmp/files/images/failed.png"]
    debug => true
  }
}

```

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [January 27, 2025, 1:28pm UTC](https://discuss.elastic.co/t/logstash-email-image-problem/373713/2 "2025-01-27T13:28:23Z")

</div>

My understanding (acquired this morning) is that to reference an image attachment in an email you need to use the content\_id (see [here](https://stackoverflow.com/questions/922898/embedding-attached-images-in-html-emails) and [here](https://stackoverflow.com/questions/24916962/what-is-the-syntax-for-using-cidattachmentid-in-e-mail-for-image-file-used-in-c)).

The Ruby mail code appears to set the content\_id to '' (see [here](https://github.com/mikel/mail/blob/d1d65b370b109b98e673a934e8b70a0c1f58cc59/lib/mail/part.rb#L14), the hash in the caller never has :content\_id set).

Check the mail that is sent. What are the content\_id headers on each attachment? If they are set, then reference them in cid: URIs when trying to embed them.

I suspect they will not be set (the assumption being that they are only of use if the sender knows them, so they have to set them). I do not see any way for the use of the email output to set them, so referencing images in attachments may not be supported.

---

<div class="post-metadata">

**Author:** ![Hannah\_J\_Swystun](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hannah_j_swystun/32/139547_2.png) [@Hannah\_J\_Swystun](https://discuss.elastic.co/u/Hannah_J_Swystun)\
**Post date:** [January 27, 2025, 1:41pm UTC](https://discuss.elastic.co/t/logstash-email-image-problem/373713/3 "2025-01-27T13:41:45Z")

</div>

Attachments =\> Works Fine (The internal url is same)  
KO = \> HTML body with image are never shown : Internal Url, External Url, Embedded  
What should i do exactly please?

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [January 27, 2025, 1:45pm UTC](https://discuss.elastic.co/t/logstash-email-image-problem/373713/4 "2025-01-27T13:45:21Z")

</div>

Review the email that is sent and see what the content\_id header on each attachment is.

---

<div class="post-metadata">

**Author:** ![Hannah\_J\_Swystun](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hannah_j_swystun/32/139547_2.png) [@Hannah\_J\_Swystun](https://discuss.elastic.co/u/Hannah_J_Swystun)\
**Post date:** [January 27, 2025, 1:59pm UTC](https://discuss.elastic.co/t/logstash-email-image-problem/373713/5 "2025-01-27T13:59:39Z")

</div>

> [@Badger](#):
>
> content\_id header on each attachment is

I did not get excplicity CONTENT-ID but something like this :

```auto
MIME-Version: 1.0
Content-Type: multipart/alternative;
	boundary="--==_mimepart_67978e0d733f8_1e21e808-3de"; charset="UTF-8"
Content-Transfer-Encoding: 7bit

```

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [January 27, 2025, 2:26pm UTC](https://discuss.elastic.co/t/logstash-email-image-problem/373713/6 "2025-01-27T14:26:56Z")

</div>

If there is no content\_id header then, as far as I understand it, you cannot reference it in a cid: URI, and cannot embed an attachment in the email.

---

<div class="post-metadata">

**Author:** ![Hannah\_J\_Swystun](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hannah_j_swystun/32/139547_2.png) [@Hannah\_J\_Swystun](https://discuss.elastic.co/u/Hannah_J_Swystun)\
**Post date:** [January 27, 2025, 2:29pm UTC](https://discuss.elastic.co/t/logstash-email-image-problem/373713/7 "2025-01-27T14:29:56Z")

</div>

I use logstash to send email depending of a query DSL from elasticsearch, so i should send mail with sunny image if everything is ok, do you have any other alternatives please ?

---

<div class="post-metadata">

**Author:** ![Hannah\_J\_Swystun](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hannah_j_swystun/32/139547_2.png) [@Hannah\_J\_Swystun](https://discuss.elastic.co/u/Hannah_J_Swystun)\
**Post date:** [January 28, 2025, 8:17am UTC](https://discuss.elastic.co/t/logstash-email-image-problem/373713/9 "2025-01-28T08:17:07Z")

</div>

What should i do exactly please, i must send automatically a mail from logstash !

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [January 28, 2025, 1:13pm UTC](https://discuss.elastic.co/t/logstash-email-image-problem/373713/10 "2025-01-28T13:13:27Z")

</div>

The email output will send email, but does not support displaying an image attachment embedded in the email.

---

<div class="post-metadata">

**Author:** ![Hannah\_J\_Swystun](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hannah_j_swystun/32/139547_2.png) [@Hannah\_J\_Swystun](https://discuss.elastic.co/u/Hannah_J_Swystun)\
**Post date:** [January 31, 2025, 9:24am UTC](https://discuss.elastic.co/t/logstash-email-image-problem/373713/11 "2025-01-31T09:24:34Z")

</div>

what a best solution, any alternative please in ELK stack please ?

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [January 31, 2025, 1:38pm UTC](https://discuss.elastic.co/t/logstash-email-image-problem/373713/12 "2025-01-31T13:38:56Z")

</div>

I don't know of a way to do that.

---

<div class="post-metadata">

**Author:** ![Hannah\_J\_Swystun](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hannah_j_swystun/32/139547_2.png) [@Hannah\_J\_Swystun](https://discuss.elastic.co/u/Hannah_J_Swystun)\
**Post date:** [January 31, 2025, 1:52pm UTC](https://discuss.elastic.co/t/logstash-email-image-problem/373713/13 "2025-01-31T13:52:28Z")

</div>

> [@Badger](#):
>
> I don't know of a way to do that.

i can send emails such as :  
input : query DSL to get some documents  
filter : aggregate those multiple documents into an HTML table  
output : send mail via SMPT

this is working but unfortunatly the images are neved shown, even they are attached correctly, but never shown in the htmlbody ! may i should buy SEARCH GUARD ! Any suggestion please
