PHP: inviare e-mail in formato HTML con la funzione mail()

PHP: inviare e-mail in formato HTML con la funzione mail()

In PHP esiste una semplice soluzione per inviare e-mail in formato HTML con la funzione mail.

La soluzione รจ la seguente:


$to = 'user@site.tld';
$subject = 'Test';
$body = '<html><head><title>' . $subject . '</title></head><body><h1>Hello world!</h1></body></html>';
$headers[] = 'MIME-Version: 1.0';
$headers[] = 'Content-type: text/html; charset=iso-8859-1';
$headers[] = 'From: Lorem Ipsum <lorem@example.tld>';

mail($to, $subject, $body, implode("\r\n", $headers));

Torna su