jokaritaff | Posté le 02-11-2006 à 10:05:06 j'ai réussi a envoyer un mail avec texte brut + html + pieces jointes
Autant sous Outlook, Outlook express tout passe nickel
Autant sur des webmails comme celui de Free, le texte brut n'est pas affiché
et en piece jointe j'ai un fichier unnamed qui contient bien le texte en brut...mais j'aimerais qu'il affiche le contneu direct plutot que de passer par le fichier unnamed
-----------------------------------------
c bon j'ai résolu mon probleme. J'avais écrit le Contenet Transfert encoding avec 8 bits au lieu de 8 bit.
Taille Puma Chaussure basket Esito 28 chaussure Fille 33 JTlKF1c3u et yavé des tabulations qui étaient pas reconnues
-------------------------------------- mon script d'envoi de mail se base sur PEAR Mail::Factory et permet donc d'envoyer : - du texte brut
- du texte html
- 1 ou n pieces jointes . par contre le Content-Type n'esty pas défini officiellement. Si vous voulez en mettre un vrai, ya le package PEAR Mail Mime.
- les mails sont tres bien gérés sur Outlook, outlook express et IMP
Si vous avez des améliorations a apporter hésitez pas a les remonter
voici le code :
Code : Adidas Tennis Chaussure Adizero 3 Chaussures De Pe19 Femme Ubersonic Y6yb7fg- include("Mail.php" );
- $eol = "\n";
- # File Taille Puma Chaussure basket Esito 28 chaussure Fille 33 JTlKF1c3ufor Attachment
- # To Email Address
- $emailaddress= $objContact->getLbEmail();
- # Message Subject
- $emailsubject="Réponse à votre question sur ".$oThemeMsg->getLbThemeMsg();
- # Message Body
- $body= $objet->getTxtMessageHtml();
- $msg = "";
- # Common Headers
- $headers['From'] = '[email protected]';
- $headers['Subject'] = $emailsubject;
- $headers["Date"] = date( "D, j M Y G:i:s O" );
- $headers["To"] = $objContact->getLbNom()." ".$objContact->getLbPrenom()." <".$objContact->getLbEmail().">";
- $headers["Reply-To"] = "[email protected]";
- //$headers .= 'Reply-To: [email protected]'.$eol;
- //$headers .= 'Return-Path: [email protected]'.$eol; // these two to set reply address
- $headers['Message-ID'] = "<".date(YmdHis)."[email protected]".$_SERVER['SERVER_NAME'].">";
- $headers['X-Mailer'] = "PHP v".phpversion(); // These two to help avoid spam-filters
Femme De Entraînement Sur Gel Fujitrabuco Asics Pour Course 5Chaussures Route CrxBode
- # Boundry for marking the split & Multitype Headers
- $mime_boundary_texte="NextPart_001_".md5(time());
- $mime_boundary_PJ="NextPart_000_".md5(time());
- $headers['MIME-Version'] .= '1.0';
- // if( $dir = @opendir($cible_dir)) {
- $headers['Content-Type'] .= "multipart/mixed;".$eol."\tboundary=\"----=_".$mime_boundary_PJ."\"";
- $msg .= "This is a multi-part message in MIME format".$eol.$eol;
- $msg .= "------=_".$mime_boundary_PJ.$eol;
- // }
- $msg .= "Content-Type: multipart/alternative;".$eol."\tboundary=\"----=_".$mime_boundary_texte."\"".$eol.$eol.$eol;
- # Text Version
- $msg .= "------=_".$mime_boundary_texte.$eol;
- $msg .= "Content-Type: text/plain;".$eol."\tcharset=\"iso-8859-1\"".$eol;
- $msg .= "Content-Transfer-Encoding: 8bit".$eol.$eol;
- $msg .= $eol.$emailsubject." :".$eol.$eol;
- $msg .= html_entity_decode($objet->getTxtMessage());
- $msg .= "\r\n\r\n-----"Performa Boots Ski Salomon 6 0 2007Evo wvNO80ymPn
- ."\r\nPS : Vous ne pouvez pas répondre directement à ce message, pour y répondre, ou donner une note de satisfaction vous devez vous rendre à l'adresse suivante :"
- . "\r\nhttp://".$_SERVER['HTTP_HOST']."/lenom/telethon.php?Page=Conversation_Contact&alea=" . $oConversation->getLbAlea()
- ."\r\n----";
- $msg .= $eol.$eol;
- # HTML Version
- $msg .= "------=_".$mime_boundary_texte.$eol;
- $msg .= "Content-Type: text/html;".$eol."\tcharset=\"iso-8859-1\"".$eol;
- $msg .= "Content-Transfer-Encoding: 8bit".$eol.$eol;
- $msg .='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'.$eol
- .'<html><head>'.$eol
- .'<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />'.$eol
- .'</head>'.$eol
- .'<body>'.$eol;
- $msg .= $emailsubject." :<br /><br />";
- $msg .= $body;
Adidas Métallique Blanches Femmes Superstar Détails Sur Chaussures 1 Baskets QrxBdeoCW- $msg .= "<br /><br />-----"
- ."\r\nPS : Vous ne pouvez pas répondre directement à ce message, pour y répondre vous devez cliquer sur ce lien :"
- . "\r\n<a href=\"http://".$_SERVER['HTTP_HOST']."/page.php">Ici</a>"
- ."\r\n----";
- $msg .= '</body>'.$eol
- .'</html>'
- .$eol.$eol;
- $msg .= "------=_".$mime_boundary_texte."--".$eol.$eol;
- if( $dir = @opendir($cible_dir)) {
- while( FALSE !== ($fich = readdir($dir)) ) {Rs Rouge De Cher Occasion Salomon Prix Pas 100 Ski Chaussure pSUVzqM
- if ($fich != "." && $fich != ".." && $fich != "CVS" ) {
- $letter = $fich;
- $content_type = substr($letter, strlen($letter)-3, strlen($letter));
- $f_name=$cible_dir.$letter; // use relative path OR ELSE big headaches. $letter is my file for attaching.
- $handle=fopen($f_name, 'rb');
- $f_contents=fread($handle, filesize($f_name));
- $f_contents=chunk_split(base64_encode($f_contents)); //Encode The Data For Transition using base64_encode();
- $f_type=filetype($f_name);
- fclose($handle);
- # Attachment
- $msg .= "------=_".$mime_boundary_PJ.$eol;
- $msg .= "Content-Type: application/$content_type; name=\"".$letter."\"".$eol; // sometimes i have to send MS Word, use 'msword' instead of 'pdf'
- $msg .= "Content-Transfer-Encoding: base64".$eol;
- $msg .= "Content-Disposition: attachment; filename=\"".$letter."\"".$eol.$eol; // !! This line needs TWO end of lines !! IMPORTANT !!
- $msg .= $f_contents.$eol.$eol;
- # Setup for text OR html
Taille Puma Chaussure basket Esito 28 chaussure Fille 33 JTlKF1c3u- //$msg .= "Content-Type: multipart/alternative".$eol;
Cross Smash Adulte Ridge Rock Chaussures Mixte V2 Puma De Grisrock dWoQrBeECx
- }
- }
- closedir($dir);
- # Finished
- }
- $msg .= "------=_".$mime_boundary_PJ."--".$eol.$eol; // finish with two eol's for better security. see Injection.
- #PREPARE MAIL
- //ini_set(sendmail_from,'[email protected]'); // the INI lines are to force the From Address to be used !
- # SEND THE EMAIL
- // envoi du mail au contact
- $params["host"] = 'smtp.domaine.fr';Taille Puma Chaussure basket Esito 28 chaussure Fille 33 JTlKF1c3u
- $params["port"] = '25';
- $params["auth"] = false;
- $params["username"] = '';
- $params["password"] = '';
- $mail_object = Mail::factory("smtp", $params);
- $mail_object->send( $emailaddress, $headers, $msg);
|
Message édité par jokaritaff le 02-11-2006 à 10:31:47
|