Page 1 sur 1

Problème envoi 2 pièces joiintes PDF par mail

Posté : 29 juil. 2023, 11:56
par ChrisCMoi62
Bonjour,
J'ai réussi à joindre 2 pièces jointes dans mon mail, quand il s'agit d'une image ça passe, mais un PDF ça ne fonctionne pas, est-ce depuis ce matin je cherche, éétant débutant je galère.

Code : Tout sélectionner

$header = "MIME-Version: 1.0\r\n"; $header .= "Content-Type: multipart/mixed; boundary=\"$boundary\"\r\n"; $header .= "\r\n"; $msg .= "--$boundary\r\n"; $msg .= "Content-Type: text/plain; charset=\"utf-8\"\r\n"; $msg .= "Content-Transfer-Encoding:8bit\r\n"; $msg .= "\r\n"; $msg .= "Ceci est un mail avec 2 fichiers joints\r\n"; $msg .= "\r\n"; $file1 = $_FILES['fichier1']['name']; $fp = fopen($file1, 'rb'); $attachment = fread($fp, filesize($file1)); fclose($fp); $attachment = chunk_split(base64_encode($attachment)); $msg .= "--$boundary\r\n"; $msg .= "Content-Type: application/pdf; name=\"$file1\"\r\n"; $msg .= "Content-Transfer-Encoding: base64\r\n"; $msg .= "Content-Disposition: inline; filename=\"$file1\"\r\n"; $msg .= "\r\n"; $msg .= $attachment . "\r\n"; $msg .= "\r\n\r\n";

Re: Problème envoi 2 pièces joiintes PDF par mail

Posté : 29 juil. 2023, 17:16
par or 1
mieux vaut utiliser une librairie pour cela :
https://github.com/PHPMailer/PHPMailer/ ... pload.phps