@ -57,12 +57,13 @@ include_spip('inc/facteur');
* @return bool
* @throws Exception
*/
function inc_envoyer_mail($destinataire, string $sujet, $message, ?string $from = '', string $headers = '') {
function inc_envoyer_mail($destinataire, string $sujet, $message, ?string $from = '', ? string $headers = '') {
if (!is_array($message)) {
$message_string = $message;
$message = [];
if (preg_match(',Content-Type:\s*text/html,ims', $headers)) {
$headers = $headers ?? '';
if ($headers and preg_match(',Content-Type:\s*text/html,ims', $headers)) {
$message['html'] = $message_string;
} else {
// Autodetection : tester si le mail est en HTML
@ -82,7 +83,7 @@ function inc_envoyer_mail($destinataire, string $sujet, $message, ?string $from
}
}
if (strlen($headers) and empty($message['headers'])) {
if (!is_null($headers) and strlen($headers) and empty($message['headers'])) {
$headers = array_map('trim', explode("\n", $headers));
$headers = array_filter($headers);
if (!empty($headers)) {