Uploaded image for project: 'ZABBIX BUGS AND ISSUES'
  1. ZABBIX BUGS AND ISSUES
  2. ZBX-19772

Broken e-mail charset

XMLWordPrintable

    • Icon: Patch request Patch request
    • Resolution: Won't fix
    • Icon: Trivial Trivial
    • None
    • 5.4.3
    • Server (S)
    • None
    • Debian GNU/Linux 10

      I've found that e-mail messages in Zabbix 5.4 have absent "charset" parameter (in the message header) which was presented in Zabbix 5.0. Now messages are sent by Zabbix with UTF-8 symbols become unreadable by some e-mail clients without expicit indication. Patch below fixes this problem by adding "charset" parameter to the "Content-Type" field.

       

      diff --git a/src/libs/zbxmedia/email.c b/src/libs/zbxmedia/email.c
      index 81df3b361d..c61f5138d4 100644
      --- a/src/libs/zbxmedia/email.c
      +++ b/src/libs/zbxmedia/email.c
      @@ -374,7 +374,7 @@ static char *smtp_prepare_payload(zbx_vector_ptr_t *from_mails, zbx_vector_ptr_t
       else
       {
       zbx_snprintf_alloc(&tmp, &tmp_alloc, &tmp_offset,
      - "Content-Type: %s\r\n"
      + "Content-Type: %s; charset=\"UTF-8\"\r\n"
       "Content-Transfer-Encoding: base64\r\n",
       ZBX_MEDIA_CONTENT_TYPE_HTML == content_type ? "text/html" : "text/plain");
       }
      @@ -873,7 +873,7 @@ char *zbx_email_make_body(const char *message, unsigned char content_type, cons
       
       zbx_snprintf_alloc(&body, &body_alloc, &body_offset,
       "--" ZBX_MULTIPART_MIXED_BOUNDARY "\r\n"
      - "Content-Type: %s\r\n"
      + "Content-Type: %s; charset=\"UTF-8\"\r\n"
       "Content-Transfer-Encoding: base64\r\n"
       "\r\n"
       "%s\r\n"
      @@ -887,7 +887,7 @@ char *zbx_email_make_body(const char *message, unsigned char content_type, cons
       
       zbx_snprintf_alloc(&body, &body_alloc, &body_offset,
       "--" ZBX_MULTIPART_MIXED_BOUNDARY "\r\n"
      - "Content-Type: %s\r\n"
      + "Content-Type: %s; charset=\"UTF-8\"\r\n"
       "Content-Transfer-Encoding: base64\r\n"
       "Content-Disposition: attachment; filename=\"%s\"\r\n"
       "\r\n" 

            zabbix.support Zabbix Support Team
            dredd Andrei Ianchenko
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: