my code

When working with German Umlaute, it happens very often, that you get some funky errors like ?sterreich or hßflich etc.
This snippet prevents your e-mail from getting broken / funky characters in your PHP mail.

Snippet options

Download: Download snippet as php-mail-encoding.php.
Copy snippet: For this you need a free my code account.
Embed code : You will find the embed code for this snippet at the end of the page, if you want to embed it into a website or a blog!


// UTF-8 Character Mail Encoding
function mail_utf8($to, $subject = '(Betreffzeile der MailBLABLA)', $message = '', $header = '') {
    $header_ = 'MIME-Version: 1.0' . "\r\n" . 'Content-type: text/plain; charset=UTF-8' . "\r\n";
    mail($to, '=?UTF-8?B?'.base64_encode($subject).'?=', $message, $header_ . $header);


Create a free my code account now.

my code is a free service, which allows you to save and manage code snippes of any kind and programming language. We provide many advantages for your daily work with code-snippets, also for your teamwork. Give it a try!

Find out more and register now

You can customize the height of iFrame-Codes as needed! You can find more infos in our API Reference for iframe Embeds.