probleme avec mail en php
Bonjour
je veux envoyer un mail avec une PJ,je recois mon mail et ma PJ mais jé un probléme dans la mise en page et j'ai un bout de code qui s'affiche dans mon mail
Code:
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 77
|
<?php
session_start();
@import_request_variables("EGPCS","");
?>
<?php
//define the receiver of the email
$to = <a href="mailto:moi@gmail.com">moi@gmail.com</a>';
//define the subject of the email
$subject = 'mail test';
//create a boundary string. It must be unique
//so we use the MD5 algorithm to generate a random hash
$random_hash = md5(date('r', time()));
//define the headers we want passed. Note that they are separated with \r\n
$headers = "From: <a href="mailto:lol@gmail.com">lol@gmail.com</a>\r\nReply-To: <a href="mailto:lol@gmail.com">lol@gmail.com</a>";
//add boundary string and mime type specification
$headers .= "\r\nContent-Type: multipart/mixed; boundary=\"PHP-mixed-".$random_hash."\"";
//read the atachment file contents into a string,
//encode it with MIME base64,
//and split it into smaller chunks
$attachment = chunk_split(base64_encode(file_get_contents('img.pdf')));
//define the body of the message.
ob_start(); //Turn on output buffering
?>
--PHP-mixed-<?php echo $random_hash; ?>
Content-Type: multipart/alternative; boundary="PHP-alt-<?php echo $random_hash; ?>"
Content-Type: text/plain; charset="iso-8859-1"'."\n";
Content-Transfer-Encoding: 8bit';
Bonjour,
<?php
echo $_SESSION['userlogin']['id'];
echo "<BR>";
$Message = "<b>Texte en Gras</b><u>Texte Souligné</u><i>Texte en Italique</i>";
echo $_SESSION['userlogin']['nom'];
echo $_SESSION['userlogin']['prenom'];
echo $_SESSION['userlogin']['email'];
?>
--PHP-alt-<?php echo $random_hash; ?>
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: 8bit
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<tr>test</tr>
<tr>Nom : <?php echo $_SESSION['userlogin']['nom'];?></tr>
<tr>Prénom : <?php echo $_SESSION['userlogin']['prenom'];?></tr>
<tr>Numéro de commande : <?php echo $_SESSION['userlogin']['email'];?></tr>
<</body>
</html>
--PHP-alt-<?php echo $random_hash; ?>--
--PHP-mixed-<?php echo $random_hash; ?>
Content-Type: application/pdf; name="img.pdf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment
<?php echo $attachment; ?>
--PHP-mixed-<?php echo $random_hash; ?>--
<?php
//copy current buffer contents into $message variable and delete current output buffer
$message = ob_get_clean();
//send the email
$mail_sent = @mail( $to, $subject, $message, $headers );
//if the message is sent successfully print "Mail sent". Otherwise print "Mail failed"
echo $mail_sent ? "msg envoyé" : "Mail failed";
?> |
mail ke je recois:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
Bonjour,
592<BR>coucou14901829.88--PHP-alt-a107456854363e412d31479e2671af28
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: 8bit
echo "<html>";
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>echo "<tr>Bonjour</tr>";
<tr>test</tr>
<tr>Nom :moi</tr>
<tr>Prénom : coucou</tr>
<tr>Numéro de commande : coucou</tr>
</body>
echo "</html>";
--PHP-alt-a107456854363e412d31479e2671af28-- |
je sais pas pk les balises d html s affiche et aussi le code en php?
Merci de votre aide