PHP - Script Simple - Unexpected $end

The_QcR -  
 The_QcR -
Bonjour,

J'ai encore un petit problème en php :P !!

J'aurais besoin d'aide pour ce script qui me permet d'envoyer des pièces jointes par email (Mais des mails en HTML)

Voici l'erreur : Parse error: syntax error, unexpected $end in /home/commint/public_html/admin/envoyer_doc_a.php on line 64

Voici mon code ! Merci de votre aide !!

<?php

// Setting a timezone, mail() uses this.
// recipients
$email = $_POST['email'];
$file = $_POST['file'];
$motifmail = $_POST['motif'];

$attachment = file_get_contents("/home/commint/public_html/dl/$file");

$HTML = "<img src='http://comm-inter-tel.ca/img/logo.jpg'></img><center><br><font face='Century Gothic' size='5'>Lien de téléchargement</font><font face='Century Gothic'><center><br>$motifmail<br><a href='http://comm-inter-tel.ca/download.php?$cdname' target='_blank'>http://comm-inter-tel.ca/download.php?$cdname</a></font>";
$from = "info@comm-inter-tel.com";
$to = $email;
$subject = "Inter-Tel.ca - Lien de téléchargement";

sendHTMLemail($HTML,$from,$to,$subject);

function sendHTMLemail($HTML,$from,$to,$subject)
{
// First we have to build our email headers
// Set out "from" address

$headers = "From: $from\r\n";

// Now we specify our MIME version

$headers .= "MIME-Version: 1.0\r\n";

// Create a boundary so we know where to look for
// the start of the data

$boundary = uniqid("HTMLEMAIL");

// First we be nice and send a non-html version of our email

$headers .= "Content-Type: multipart/alternative;".
"boundary = $boundary\r\n\r\n";

$headers .= "This is a MIME encoded message.\r\n\r\n";

$headers .= "--$boundary\r\n".
"Content-Type: text/plain; charset=ISO-8859-1\r\n".
"Content-Transfer-Encoding: base64\r\n\r\n";

$headers .= chunk_split(base64_encode(strip_tags($HTML)));

// Now we attach the HTML version

$headers .= "--$boundary\r\n".
"Content-Type: text/html; charset=ISO-8859-1\r\n".
"Content-Transfer-Encoding: base64\r\n\r\n";

$headers .= "Content-Type: application/octet-stream; name=$file".
"Content-Transfer-Encoding: base64\r\n\r\n".
"Content-Disposition: attachment";

$headers .= chunk_split(base64_encode($HTML));

?>
Configuration: Windows XP Internet Explorer 6.0

12 réponses

  1. jeangilles Messages postés 816 Date d'inscription   Statut Membre Dernière intervention   186
     
    Rajoutes un } juste avant le ?> de la fin
    0
  2. The_QcR
     
    MERCI JEANGILLES !!
    tu es génial ! :P

    quand on ouvre une fonction on doit la fermer en ;)

    Mais je comprend pas car je reçois pas le mail :O
    0
  3. jeangilles Messages postés 816 Date d'inscription   Statut Membre Dernière intervention   186
     
    ben moi ca métonne pas vraiment ^^
    ajoutes à la fin de la fonction

    mail ($to, $subject ,
    $HTML, $headers);
    0
  4. The_QcR
     
    LOLLLL .... C'est bon .... je sort ! :P

    Merci tout de même
    0
  5. Vous n’avez pas trouvé la réponse que vous recherchez ?

    Posez votre question
  6. The_QcR
     
    Ya toutde même un problème !! Je reçois un e-mail mais ya rien dedans et sa m'indique qu'il y une pièce jointe mais il y en pas !!
    0
  7. jeangilles Messages postés 816 Date d'inscription   Statut Membre Dernière intervention   186
     
    Ben la piece jointe cest parce que tas mis

    $headers .= "Content-Type: application/octet-stream; name=$file".
    "Content-Transfer-Encoding: base64\r\n\r\n".
    "Content-Disposition: attachment";

    et pour le contenu, javais pensé que cétait la variable $HTML qui était passé en parametre, si cest pas ca faut faire un truc dans ce genre là ^^
    0
  8. The_QcR
     
    Mmmm.... Mais j'ai trouver qqch de fonctionnel sur le web qui fonctionne beaucoup mieux mais la ligne :

    Content-Type: application/octet-stream; name=$file

    fait que le fichier que je reçois est $file ... mais je voudrais plutôt recevoir la valeur de $file ! Car le fichier change à chaque envoi !
    0
  9. The_QcR
     
    Y'aurais pas un pro de php ds les parages pour m'aider svp ?? :)

    Merci d'avance :P
    0
  10. jeangilles Messages postés 816 Date d'inscription   Statut Membre Dernière intervention   186
     
    ben si tu mets 'Content-Type: application/octet-stream; name=$file', c'est sur que cest la chaine de caractères $file qui sera envoyés

    par contre si tu mets "Content-Type: application/octet-stream; name=$file " (avec des " à la place des ') là c'est ta variable $file sera interprétée comme une variable justement
    0
  11. The_QcR
     
    Ouais, ça je savais mais regarde, il n'y a pas de guillemets nulle part alors je sais pas trop !
    Regarde cette portion du code

    --PHP-alt-<?php echo $random_hash; ?>--

    --PHP-mixed-<?php echo $random_hash; ?>
    Content-Type: application/octet-stream; name=$file
    Content-Transfer-Encoding: base64
    Content-Disposition: attachment

    <?php echo $attachment; ?>
    --PHP-mixed-<?php echo $random_hash; ?>--

    j'ai même essayer de mettre \"$file\" mais sa ne fonctionne pas plus !!

    --PHP-alt-<?php echo $random_hash; ?>--

    --PHP-mixed-<?php echo $random_hash; ?>
    Content-Type: application/octet-stream; name=\"$file\"
    Content-Transfer-Encoding: base64
    Content-Disposition: attachment

    <?php echo $attachment; ?>
    --PHP-mixed-<?php echo $random_hash; ?>--
    0
  12. jeangilles Messages postés 816 Date d'inscription   Statut Membre Dernière intervention   186
     
    ton $file n'est pas entre les balises php !

    <.php echo "$random_hash
    Content-Type: application/octet-stream; name=$file
    Content-Transfer-Encoding: base64
    Content-Disposition: attachment "; ?>
    0
  13. The_QcR
     
    Super !! Merci beaucoup :P

    t'es vraiment fort !!
    0