I wrote a C++ application that needs to send emails.
It does this by calling
/usr/sbin/sendmail -f [sender] -t
and then writing the mail headers and body to the standard input of the sendmail process.
Everything works fine – except for umlauts or other non-ASCII characters.
How can I make them working correctly?
I already tried to set
Content-Type: plain-text; charset=ISO-8859-1
as a mail header and also
Content-Type: plain-text; charset=UTF-8
didn’t change anything. Seems like this header is ignored.
Anything other than ASCII in an email message should typically be encoded either as quoted-printable or base64. The
Content-Transfer-EncodingandContent-Typeheaders are then set accordingly so that the recipient knows how to decode the message back to non-ASCII text.Here’s a bash example that illustrates how this can be done on the command line:
You need to specify whatever character encoding was used to convert the string to binary before the data was base64 encoded.
This example uses utf-8, because that is a common platform default so most shells would use utf-8 when converting the string to binary and passing it to
base64on stdin.