1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
| <?php
// Setting a timezone, mail() uses this.
date_default_timezone_set('America/New_York');
// recipients
$to = 'emaaaail' ;
// subject
$subject = "Collection x";
// Create a boundary string. It needs to be unique
$sep = sha1(date('r', time()));
$headers = "From:emaiil\r\n";
// Add in our content boundary,
// and mime type specification:
$headers .="\r\nContent-Type: multipart/alternative; boundary=\"PHP-mixed-{$sep}\" ";
// Read in our file attachment
$attachment = file_get_contents('fichiers/'.$name.'.zip' );
$encoded = base64_encode($attachment);
$attached = chunk_split($encoded);
$attachment2 = file_get_contents('MesPV/PV_A_'.$namee.'.pdf' );
$encoded = base64_encode($attachment2);
$attached2 = chunk_split($encoded);
// additional headers
//$headers .= "To: emailll \r\n";
// Your message here:
$body = "
--PHP-mixed-{$sep}
Content-Type: multipart/alternative; boundary=\"PHP-alt-{$sep}\"
--PHP-alt-{$sep}
Content-Type: text/html; charset=\"iso-8859-1\"
Content-Transfer-Encoding: 7bit
<h3>Bien le bonjour!</h3>
<p>Vous trouverez c-joint toute la collection et PV. Cordialement.</p>
--PHP-alt-{$sep}--
--PHP-mixed-{$sep}
Content-Type: application/pdf; name=\"PV_A_".$namee.".pdf\"
Content-Transfer-Encoding: base64
Content-Disposition: attachment2
{$attached2}
--PHP-mixed-{$sep}
Content-Type: application/zip; name=\"".$name.".zip\"
Content-Transfer-Encoding: base64
Content-Disposition: attachment
{$attached}
--PHP-mixed-{$sep}-- ";
// Finally, send the email
if (mail($to, $subject, $body, $headers)){
echo "The mail has been sent.";
} else {
echo "The mail has NOT been sent!";
}
?> |
Partager