0

I am using direct conversation with Port 25 to send bulk email.

However, some mail servers refuse unencoded umlauts in the header values and I can´t seem to figure out how to properly encode them.

All I could find was hints to the php mail function or some mailing libraries.

ContentType: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

I have tried

  • quoted_printable_encode throws 'illegal character' Notices
  • utf8_encode has no effect at all
  • iconv_mime_encode($key, $val, ['scheme'=>'Q','input-charset'=>'ISO-8859-1'] leads to something like '=?UTF-8?Q?Dr=C3=BCnnen=20' in the Sender header, while subject and content are okay (at the problematic provider); but Thunderbird for my other account shows "�" in both list and detail view now. (the list view was okay without encoding)
  • max(array_keys(count_chars($val, 1)))>126 && $val = "=?ISO-8859-1?q?". quoted_printable_encode($val); -> shows as is at both recipients
  • $val = '=?UTF-8?B?'.base64_encode($val).'?='; almost does the trick; mails are accepted, unfortunately; Umlauts are still displayed as �

may add further examples during my tryouts. Any hints are very welcome.

Titus
  • 452
  • 8
  • 19
  • *"Any hints are very welcome"* Use a library? – Olivier Aug 17 '23 at 14:13
  • This charset does not support umlauts. You need `charset=ISO8859-15`. – Markus Zeller Aug 17 '23 at 14:21
  • @MarkusZeller ISO-8859-1 does support umlauts (as you can see [here](https://en.wikipedia.org/wiki/ISO/IEC_8859-1#Code_page_layout)). – Olivier Aug 17 '23 at 14:28
  • And the correct spelling is `ISO-8859-1` (with 2 hyphens). – Olivier Aug 17 '23 at 14:33
  • Switch to [UTF-8 Everywhere](https://utf8everywhere.org/); see also [UTF-8 all the way through](https://stackoverflow.com/questions/279170/). – JosefZ Aug 17 '23 at 19:03
  • 1
    @MarkusZeller 8859-1 does not support the Euro sign; 8859-15 does. only difference between the two, afaik. – Titus Aug 17 '23 at 19:43
  • @Olivier "ISO-..." Typo here; not in the Code. Thx for hinting. Do You know a library where I can just exchange "mail" with another function name? – Titus Aug 17 '23 at 19:44
  • @JosefZ UTF-8 is on its way, but there´s another hassle with that. Currently, I am looking for a solution with ISO-8859-1 (or -15). Thanks for the links though. – Titus Aug 17 '23 at 19:48
  • 1
    _"`$val = '=?UTF-8?B?'.base64_encode($val).'?=';` almost does the trick; mails are accepted, unfortunately; Umlauts are still displayed as �"_ - if you did not convert your input `$val` to UTF-8 first, then this header would still not be telling the truth ... With actual UTF-8 encoded data, it should work fine: https://3v4l.org/ddW7N – CBroe Aug 18 '23 at 08:38

0 Answers0