Précédent   Forum des professionnels en informatique > PHP > Langage > Fonctions
Fonctions Forum d'entraide sur les fonctions PHP. Avant de poster -> FAQ fonctions et Sources diverses
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 31/05/2011, 14h47   #1
Invité de passage
 
Homme
Étudiant
Inscription : mai 2011
Messages : 2
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : France

Informations professionnelles :
Activité : Étudiant

Informations forums :
Inscription : mai 2011
Messages : 2
Points : 0
Points : 0
Par défaut Fonction mail, la pièce jointe n'apparaît pas

Bonjour à tous,
voici mon problème :
j'utilise la fonction mail de php afin de faire parvenir des informations dont des documents textes uplaudés sur le serveur qui héberge mon site.
J'arrive à envoyer mon mail via un script trouvé sur internet sauf qu'à la réception de celui-ci, ni la pièce jointe, ni le texte ne sont visible (alors que tout est pourtant bien présent).

Voici le code source du mail (j'ai coupé les informations concernant la pièce jointe pour alléger) :

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
 
Return-Path: <mail_php@bcpartners.biz>
Delivered-To: bcpartners2.com-test@bcpartners2.com
Received: (qmail 20079 invoked from network); 31 May 2011 10:54:53 -0000
Received: from unknown (HELO 88-190-253-82) (88.190.253.82)
  by qmail-13.online.net with SMTP; 31 May 2011 10:54:53 -0000
Received: from [88.190.253.253] (helo=mailler1.lwserv1.com)
	by 88-190-253-82 with smtp (Exim 4.71)
	(envelope-from <mail_php@bcpartners.biz>)
	id 1QRMb7-0007HW-Rg
	for test@bcpartners2.com; Tue, 31 May 2011 12:54:53 +0200
Received: from mailler1.lwserv1.com ([80.248.217.22])
	by mx-vit.online.net (MXproxy) for test@bcpartners2.com ;
	Tue, 31 May 2011 12:54:45 +0200 (CEST)
X-ProXaD-SC: state=SPAM score=180
Received: from webdb2-vps.lws-hosting.com ([193.37.145.77])
	by mailler1.lwserv1.com
	; Tue, 31 May 2011 13:04:43 +0200
To: test@bcpartners2.com
Subject: test html
MIME-Version: 1.0
X-MSMail-Priority: Normal
X-Mailer: php
From: "test" <test@hotmail.com>
Reply-To: "NO-REPLY" <no-reply@test.com>
Content-Type: multipart/mixed; boundary="----=_parties_c65b65c04248dfaf3a5218e96ad090c5"\n\n
Date: Tue, 31 May 2011 12:53:23 +0200
Message-Id: <1306839203.121423.3480@webdb2-vps.lws-hosting.com>
X-online-to: test@bcpartners2.com
 
------=_parties_c65b65c04248dfaf3a5218e96ad090c5
Content-Type: application/msword; name="CV_de_..."
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="CV_de_..."
 
0M8R4KGxGuEAAAAAAAAAAAAAAAAAAAAAPgADAP7/CQAGAAAAAAAAAAAAAAABAAAAKAAAAAAAAAAA
EAAAKgAAAAEAAAD+////AAAAACcAAAD.....
------=_parties_c65b65c04248dfaf3a5218e96ad090c5
Content-type: text/plain; charset="iso-8859-1"
 
test
Je peux aussi mettre le code de la fonction mail si cela est utile.
BCPJulien est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 01/06/2011, 09h18   #2
Invité de passage
 
Homme
Étudiant
Inscription : mai 2011
Messages : 2
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : France

Informations professionnelles :
Activité : Étudiant

Informations forums :
Inscription : mai 2011
Messages : 2
Points : 0
Points : 0
Bonjour,
comme personne ne répond, je rajoute le code de ma fonction mail si ça peut aider à résoudre mon problème :

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
78
79
80
81
82
83
84
 
SEND_MAIL($fromname, $fromaddress, $rplname, $rpladdress, $toaddress, $subject, $message, $pieces_jointes = "", $charset = "iso-8859-1", $format_HTML = true){
		$msg = ""; // Message a renvoyer a la fonction mail() PHP
 
		/* Separateur */
		$limite = '_parties_'.md5( uniqid( rand() ) );
 
		/* Gestion des headers */
		$headers  = "MIME-Version: 1.0\n";
		$headers .= "X-MSMail-Priority: Normal\n";
		$headers .= "X-Mailer: php\n";
 
		if( $fromname == "" ){
			$headers .= "From: ".$fromaddress."\n";
		}else{
			$headers .= "From: \"".$fromname."\" <".$fromaddress.">\n";
		}
 
		if( $rplname == "" && $rpladdress != "" ){
			$headers .= "Reply-To: ".$rpladdress."\n";
		}elseif( $rplname != "" && $rpladdress != "" ){
			$headers .= "Reply-To: \"".$rplname."\" <".$rpladdress.">\n";
		}
 
		$headers .= 'Content-Type: multipart/mixed; boundary="----='.$limite.'"\n\n';
 
		/* Gestion des pièces jointes */
		if( is_array( $pieces_jointes ) && !empty( $pieces_jointes ) ){
			$fichier = array();
			$i = 0;
			foreach( $pieces_jointes as $pj ){
				$fichier[$i]['CONTENU'] = file_get_contents( $pj );
 
				// Recuperation du type mime du fichier ( mime_content_type() : fonction PHP de base obsolète à partir de PHP 5.3 mais fonctionne encore sur les sites OVH)
				$fichier[$i]['MIME'] = mime_content_type( $pj );
 
 
				$temp_nom_complet = explode("/", $pj);
				$temp_nom_comp = explode(".", $temp_nom_complet[ count($temp_nom_complet)-1 ]);
				$temp_nom = array();
				$j = count($temp_nom_comp) - 2;
 
				for( $l=0 ; $l <= $j ; $l++ ){
					$temp_nom[] = $temp_nom_comp[$l];
				}
 
				$temp_tab_nom = count( $temp_nom ) - 1;
 
				$k = 0;
				$fichier[$i]['NOM'] = "";
				foreach( $temp_nom as $temp ){
					if( $k !=  $temp_tab_nom ){
						$fichier[$i]['NOM'] .= $temp.".";
					}else{
						$fichier[$i]['NOM'] .= $temp;
					}
					$k++;
				}
 
				$fichier[$i]['BASE64'] = chunk_split( base64_encode( $fichier[$i]['CONTENU'] ) );
 
				$msg .= "------=".$limite."\n";
				$msg .= "Content-Type: ".$fichier[$i]['MIME']."; name=\"".$fichier[$i]['NOM']."\"\n";
				$msg .= "Content-Transfer-Encoding: base64\n";
				$msg .= "Content-Disposition: attachment; filename=\"".$fichier[$i]['NOM']."\"\n\n";
				$msg .= $fichier[$i]['BASE64'];
 
				$i++;
 
			}
		}
 
		/* Corps du mail HTML */
		$msg .= "------=".$limite."\n";
		if( $format_HTML ){
			$msg .= "Content-type: text/html; charset=\"".$charset."\"\n\n";
		}else{
			$msg .= "Content-type: text/plain; charset=\"".$charset."\"\n\n";
		}
 
		$msg .= $message;
		return mail($toaddress, $subject, $msg, $headers);
 
	}
Il faut savoir que c'est une fonction que j'ai trouvé en libre accès sur internet car je n'avais encore jamais utilisé la fonction mail() de php.

J'espère ne pas m'être trompé de section.
BCPJulien est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 17h42.


 
 
 
 
Partenaires

Hébergement Web