// Created on savesnippets.com ยท https://savesnippets.com/MeBXgdNtkSKF2b $from, 'Reply-To' => $from, 'MIME-Version' => '1.0', 'Content-Type' => 'text/plain; charset=UTF-8', 'X-Mailer' => 'PHP/' . PHP_VERSION, ]; $headerLines = ''; foreach ($headers as $k => $v) $headerLines .= "$k: $v\r\n"; // Encode the subject so non-ASCII renders correctly. $subject = '=?UTF-8?B?' . base64_encode($subject) . '?='; return mail($to, $subject, $body, $headerLines); } sendEmail('user@example.com', 'Welcome!', "Thanks for signing up.\n", 'noreply@myapp.com');