diun icon indicating copy to clipboard operation
diun copied to clipboard

Hostname with "_" does not appear correctly in email notifications

Open steakhutzeee opened this issue 3 years ago • 4 comments

Behaviour

Steps to reproduce this issue

I added to my compose file:

hostname: dk_diun

Expected behaviour

Hostname to appear in email notification

Actual behaviour

The hostname in the emails appears like:

(triggered by _dk diun host)

Configuration

  • Diun version : latest
  • Platform (windows/linux) : linux
  • System info (type uname -a) : Linux DK 4.14.222-odroidxu4 #1 SMP PREEMPT Mon Nov 22 12:13:27 UTC 2021 armv7l GNU/Linux

steakhutzeee avatar Jul 22 '22 19:07 steakhutzeee

Can you post your compose file and diun yaml configuration (if applicable) please?

And also source of the email would help thx!

crazy-max avatar Jul 22 '22 19:07 crazy-max

Sure:

version: "3.5"
services:
  diun:
    image: crazymax/diun:latest
    container_name: diun
    hostname: dk_diun
    environment:
      - TZ=Europe/Rome
      - LOG_LEVEL=info
      - LOG_JSON=false
      - DIUN_WATCH_WORKERS=20
      - DIUN_WATCH_SCHEDULE=0 */6 * * *
      - DIUN_PROVIDERS_DOCKER=true
      - DIUN_PROVIDERS_DOCKER_WATCHBYDEFAULT=true
      - DIUN_NOTIF_MAIL_HOST=xxx
      - DIUN_NOTIF_MAIL_PORT=xxx
      - DIUN_NOTIF_MAIL_SSL=true
      - DIUN_NOTIF_MAIL_LOCALNAME=localhost
      - DIUN_NOTIF_MAIL_USERNAME=xxx
      - DIUN_NOTIF_MAIL_PASSWORD=xxx
      - DIUN_NOTIF_MAIL_FROM=xxx
      - DIUN_NOTIF_MAIL_TO=xxx
    volumes:
      - /srv/dev-disk-by-label-HC2/AppData/diun/data:/data
      - /var/run/docker.sock:/var/run/docker.sock
      - profiler:/profiler
    restart: always
    dns:
      - 1.1.1.1
      - 1.0.0.1
networks:
    default:
      external:
        name: my-net

volumes:
  profiler:

steakhutzeee avatar Jul 22 '22 19:07 steakhutzeee

Here is message source:


Return-Path: <xxx>
Received: from localhost (xxx. [xxx])
        by xxx with xxx
        for <xxx>
        (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256);
        Thu, 21 Jul 2022 21:00:10 -0700 (PDT)
Message-ID: <[email protected]>
Mime-Version: 1.0
Date: Fri, 22 Jul 2022 06:00:10 +0200
From: Diun <xxx>
To: xxx
Subject: docker.io/amir20/dozzle:latest has been updated
Content-Type: multipart/alternative;
 boundary=7b736b61d1ec470f3c0a3e545f08805fc1fa8667f6bdc9438cde352bde9d

--7b736b61d1ec470f3c0a3e545f08805fc1fa8667f6bdc9438cde352bde9d
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8

-------------------
Diun =F0=9F=94=94 notification
-------------------

Docker tag *docker.io/amir20/dozzle:latest* ( https://github.com/amir20/doz=
zle ) which you subscribed to through docker provider has been updated on *=
docker.io* registry (triggered by _dk diun host).

This image has been updated at Jul 21, 2022 23:55:21 UTC with digest sha256=
:6b4ac0ea2da5a58933ec7f1414393c50a848040d92ed035a0396c40b34c224e5 for linux=
/arm/v7 platform.

Need help, or have questions? Go to https://github.com/crazy-max/diun and l=
eave an issue.

Thanks for your support!,
Diun - https://github.com/crazy-max/diun

CrazyMax =C2=A9 2022 Diun 4.22.0
--7b736b61d1ec470f3c0a3e545f08805fc1fa8667f6bdc9438cde352bde9d
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.=
w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns=3D"http://www.w3.=
org/1999/xhtml"><head>
  <meta name=3D"viewport" content=3D"width=3Ddevice-width, initial-scale=3D=
1.0"/>
  <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DUTF-8"/=
>
 =20
<style type=3D"text/css">*:not(br):not(tr):not(html) {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Aria=
l, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol" !im=
portant;
-webkit-box-sizing: border-box !important;
box-sizing: border-box !important
}cite:before {
content: "\2014 \0020" !important
}@media only screen and (max-width: 600px){
.email-body_inner,
      .email-footer {
width: 100% !important
}
}
@media only screen and (max-width: 500px){
.button {
width: 100% !important
}
}
</style></head>
<body dir=3D"ltr" style=3D"height:100%;margin:0;line-height:1.4;background-=
color:#F2F4F6;color:#74787E;-webkit-text-size-adjust:none;width:100%">
  <table class=3D"email-wrapper" width=3D"100%" cellpadding=3D"0" cellspaci=
ng=3D"0" style=3D"width:100%;margin:0;padding:0;background-color:#F2F4F6">
    <tbody><tr>
      <td class=3D"content" style=3D"color:#74787E;font-size:15px;line-heig=
ht:18px;align:center;padding:0">
        <table class=3D"email-content" width=3D"100%" cellpadding=3D"0" cel=
lspacing=3D"0" style=3D"width:100%;margin:0;padding:0">
         =20
          <tbody><tr>
            <td class=3D"email-masthead" style=3D"color:#74787E;font-size:1=
5px;line-height:18px;padding:25px 0;text-align:center">
              <a class=3D"email-masthead_name" href=3D"https://github.com/c=
razy-max/diun" target=3D"_blank" style=3D"font-size:16px;font-weight:bold;c=
olor:#2F3133;text-decoration:none;text-shadow:0 1px 0 white">
               =20
                  <img src=3D"https://raw.githubusercontent.com/crazy-max/d=
iun/master/.res/diun.png" class=3D"email-logo" style=3D"max-height:128px"/>
               =20
                </a>
            </td>
          </tr>

         =20
          <tr>
            <td class=3D"email-body" width=3D"100%" style=3D"color:#74787E;=
font-size:15px;line-height:18px;width:100%;margin:0;padding:0;border-top:1p=
x solid #EDEFF2;border-bottom:1px solid #EDEFF2;background-color:#FFF">
              <table class=3D"email-body_inner" align=3D"center" width=3D"5=
70" cellpadding=3D"0" cellspacing=3D"0" style=3D"width:80%;margin:0 auto;pa=
dding:0">
               =20
                <tbody><tr>
                  <td class=3D"content-cell" style=3D"color:#74787E;font-si=
ze:15px;line-height:18px;padding:35px">
                    <h1 style=3D"margin-top:0;color:#2F3133;font-size:19px;=
font-weight:bold">Diun =F0=9F=94=94 notification</h1>
                   =20
                   =20
                      <p style=3D"margin-top:0;color:#74787E;font-size:16px=
;line-height:1.5em">Docker tag <a href=3D"https://github.com/amir20/dozzle"=
 style=3D"color:#3869D4"><strong>docker.io/amir20/dozzle:latest</strong></a=
>
which you subscribed to through docker provider has been updated
on <strong>docker.io</strong> registry (triggered by _dk<em>diun</em> host)=
.</p>

<p style=3D"margin-top:0;color:#74787E;font-size:16px;line-height:1.5em">Th=
is image has been updated at
<code style=3D"font-family:SFMono-Regular,Consolas,&#34;Liberation Mono&#34=
;,Menlo,Courier,monospace;color:#c7254e;padding:.2em .4em;margin:0;font-siz=
e:85%;background-color:rgba(27,31,35,.05);border-radius:3px">Jul 21, 2022 2=
3:55:21 UTC</code> with digest <code style=3D"font-family:SFMono-Regular,Co=
nsolas,&#34;Liberation Mono&#34;,Menlo,Courier,monospace;color:#c7254e;padd=
ing:.2em .4em;margin:0;font-size:85%;background-color:rgba(27,31,35,.05);bo=
rder-radius:3px">sha256:6b4ac0ea2da5a58933ec7f1414393c50a848040d92ed035a039=
6c40b34c224e5</code>
for <code style=3D"font-family:SFMono-Regular,Consolas,&#34;Liberation Mono=
&#34;,Menlo,Courier,monospace;color:#c7254e;padding:.2em .4em;margin:0;font=
-size:85%;background-color:rgba(27,31,35,.05);border-radius:3px">linux/arm/=
v7</code> platform.</p>

<p style=3D"margin-top:0;color:#74787E;font-size:16px;line-height:1.5em">Ne=
ed help, or have questions? Go to <a href=3D"https://github.com/crazy-max/d=
iun" style=3D"color:#3869D4">https://github.com/crazy-max/diun</a> and leav=
e an issue.</p>

                   =20
                   =20

                    <p style=3D"margin-top:0;color:#74787E;font-size:16px;l=
ine-height:1.5em">
                      Thanks for your support!
                    </p>

                   =20
                  </td>
                </tr>
              </tbody></table>
            </td>
          </tr>
          <tr>
            <td style=3D"padding:10px 5px;color:#74787E;font-size:15px;line=
-height:18px">
              <table class=3D"email-footer" align=3D"center" width=3D"570" =
cellpadding=3D"0" cellspacing=3D"0" style=3D"width:80%;margin:0 auto;paddin=
g:0;text-align:center">
                <tbody><tr>
                  <td class=3D"content-cell" style=3D"color:#74787E;font-si=
ze:15px;line-height:18px;padding:35px">
                    <p class=3D"sub center" style=3D"margin-top:0;line-heig=
ht:1.5em;color:#AEAEAE;font-size:12px;text-align:center">
                      CrazyMax =C2=A9 2022 Diun 4.22.0
                    </p>
                  </td>
                </tr>
              </tbody></table>
            </td>
          </tr>
        </tbody></table>
      </td>
    </tr>
  </tbody></table>


</body></html>
--7b736b61d1ec470f3c0a3e545f08805fc1fa8667f6bdc9438cde352bde9d--

steakhutzeee avatar Jul 22 '22 19:07 steakhutzeee

Looking at the source of the email it seems broken for text/plain and text/html :disappointed::

Docker tag *docker.io/amir20/dozzle:latest* ( https://github.com/amir20/doz=
zle ) which you subscribed to through docker provider has been updated on *=
docker.io* registry (triggered by _dk diun host).
                      <p style=3D"margin-top:0;color:#74787E;font-size:16px=
;line-height:1.5em">Docker tag <a href=3D"https://github.com/amir20/dozzle"=
 style=3D"color:#3869D4"><strong>docker.io/amir20/dozzle:latest</strong></a=
>
which you subscribed to through docker provider has been updated
on <strong>docker.io</strong> registry (triggered by _dk<em>diun</em> host)=
.</p>

I guess this is an issue with hermes in: https://github.com/crazy-max/diun/blob/21f5d0839a630a2f2b75e64e41aa3f3d7b37198e/internal/notif/mail/client.go#L73

We might need to do something like the telegram notif to escape some markdown syntax: https://github.com/crazy-max/diun/blob/387ee68e7220d12573aac7f7c9b4911f8c9a2167/internal/notif/telegram/client.go#L65-L72

Will take a look, thanks for your report!

crazy-max avatar Jul 22 '22 19:07 crazy-max