Vous aurez besoin de XPM4-v.0.5.zip (voir section download)
<?php // manage errors error_reporting(E_ALL); // php errors define('DISPLAY_XPM4_ERRORS', true); // display XPM4 errors // path to 'MIME.php' file from XPM4 package require_once 'XPM4-v.0.5/SMTP.php'; $from = 'football@domain.com'; $to = 'my.address@laposte.net'; $subject = "Hi from san php!"; $text = "Test mail mime with php and XPM4...\nCool...\nSuper!\nGreat.\n\n\nyeah!\n"; // get ID value (random) for the embed image $id = MIME::unique(); $html = "<h1>Test Email leo-stitch</h1>". "<b><u>Ceci est un document HTML</u></b><br></img src=\"cid:".$id."\">" . "Avec differentes tailles de caractères et <font color=\"red\">couleurs</font>" ; $host = "ssl://relay.mail.gandi.net"; $port = "465"; $username = "football@domain.com"; $password = "unix au buro"; $smtp_host='relay.mail.gandi.net'; // connect to MTA server (relay) 'smtp.hostname.tld' via SSL (TLS encryption) with authentication using port '465' and timeout '10' secounds // make sure you have OpenSSL module (extension) enable on your php configuration //$smtp = SMTP::connect($smtp_host, 465, $username, $password, 'https', 10); /*$smtp = SMTP::connect($smtp_host, 25, $username, $password);*/ // CONFIGURATION ------------------ $smtp = SMTP::connect($smtp_host, 25, $username, $password); // print result if ($smtp) echo 'Successfully connected !'; else print_r($_RESULT); // <- for debugging // set text/plain version of message $msg1 = MIME::message($text, 'text/plain'); // set text/html version of message $msg2 = MIME::message($html, 'text/html'); $file = "sanmailWithMime.php"; $at[] = MIME::message(file_get_contents($file), 'text/plain', 'sanmailWithMime.php', 'ISO-8859-1', 'base64', 'attachment'); $file = 'Leo_et_Stitch.jpg'; // add inline attachment '$file' with name 'XPM.gif' and ID '$id' $at[] = MIME::message(file_get_contents($file), FUNC::mime_type($file), $file, // Nom du fichier dans l'attachement null, 'base64', 'attachment'); $at[] = MIME::message(file_get_contents($file), FUNC::mime_type($file), $file, // Nom du fichier dans l'attachement null, 'base64', 'inline', $id ); // compose message in MIME format $mess = MIME::compose($msg1, $msg2, $at); // standard mail message RFC2822 $body = 'From: '.$from."\r\n". 'To: '.$to."\r\n". 'Subject: '.$subject."\r\n". $mess['header']."\r\n\r\n". $mess['content']; print $body; $sent = SMTP::send($smtp, array($to), $body, $from); if ($sent) echo 'Sent !'; else print_r($_RESULT); /* // send mail relay using '$c' resource connection if ($m->Send($smtp)) { echo("<p>Message successfully sent!</p>"); } else { echo("<p>error</p>"); } */ ?>