<?php
function sendEmail(string $to, string $subject, string $body, string $from): bool {
$headers = [
'From' => $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');
Create a free account and build your private vault. Share publicly whenever you want.