Précédent   Forum des professionnels en informatique > PHP > Outils
Outils Forum d'entraide sur les outils pour développeurs PHP : EDI, installation, administration... Avant de poster : FAQ outils, toutes les FAQ PHP et les comparatifs
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 16/05/2011, 15h11   #1
Membre actif
 
Avatar de FrankOVD
 
Inscription : juin 2005
Messages : 407
Détails du profil
Informations forums :
Inscription : juin 2005
Messages : 407
Points : 182
Points : 182
Envoyer un message via MSN à FrankOVD
Par défaut Fonction d'envoi de courriel a cessé de fonctionner.

Bonjour,

J'ai cette fonction standard qui a toujours fonctionné et, du jour au lendemain, elle a cessé de fonctionner. J'utilise PHP 5.2 et je n'ai fait aucune mise à jour sur le serveur. Mon serveur SMTP fonctionne bien car je peux toujours envoyer des courriels simples, les courriels avec pièce jointe ne partent plus. J'aimerais avoir vos commentaires quant à la forme du courriel généré au cas où ce serait cette forme qui ne correspondrait plus à des standards plus stricts.

Note : La fonction retourne true même lorsque le courriel n'est pas envoyé...

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
function sendmail($to, $from, $subject, $body, $file = NULL, $filename = NULL, $hash = NULL, $confirmer_reception = true) {
	if($hash == NULL) $random_hash = $random_hash = md5(date('r', time()));
	else $random_hash = $hash;
	$config = get_config();
 
	ini_set("SMTP", $config["smtp"]); 
	ini_set('sendmail_from', $from);
	$headers  = "From: Sender <".$from.">\r\nReply-To: Receiver <".$from.">\r\n";
	if($confirmer_reception == true) {
		$headers .= "Return-Receipt-To: ".$from."\r\n";
		$headers .= "Disposition-Notification-To: ".$from."\r\n";
	}
	if($file != NULL) {
		$headers .= "Content-Type: multipart/mixed; boundary=\"PHP-mixed-".$random_hash."\"";
		$logo = chunk_split(base64_encode(file_get_contents("../img/logo_couleur.png")));
		ob_start();
		print("--PHP-mixed-".$random_hash."\r\n"); 
		print("Content-Type: multipart/alternative; boundary=\"PHP-alt-".$random_hash."\"\r\n\r\n");
		print("--PHP-alt-".$random_hash ."\r\n");
		print("Content-Type: text/HTML; charset=\"iso-8859-1\"\r\n");
		print("Content-Transfer-Encoding: 7bit\r\n\r\n");
		print($body."\r\n");
		print("--PHP-alt-".$random_hash."--\r\n\r\n");
		if($filename != NULL) { 
	  	$attachment = chunk_split(base64_encode(file_get_contents($file)));
			print("--PHP-mixed-".$random_hash."\r\n");
			print("Content-Type: application/pdf; name=\"".basename($filename)."\"\r\n");
			print("Content-Transfer-Encoding: base64 \r\n");
			print("Content-Disposition: attachment \n\n");
			print($attachment."\n\n");
			print("--PHP-alt-".$random_hash."--\r\n");
		}
		print("--PHP-mixed-".$random_hash."\r\n");
		print("Content-Type: image/png; name=\"logo.png\"\r\n");
		print("Content-Transfer-Encoding: base64 \r\n");
		print("Content-Disposition: attachment \n\n");
		print($logo."\n\n");
		print("--PHP-alt-".$random_hash."--\r\n");
		$body = ob_get_clean();
	}
	else $headers .= "Content-Type: text/HTML; boundary=\"PHP-alt-".$random_hash."\"";
 
	return mail($to, $subject, $body, $headers);
}
__________________
http://www.overdrunk.net

Pensez à la balise
FrankOVD est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 16/05/2011, 17h12   #2
Membre actif
 
Avatar de FrankOVD
 
Inscription : juin 2005
Messages : 407
Détails du profil
Informations forums :
Inscription : juin 2005
Messages : 407
Points : 182
Points : 182
Envoyer un message via MSN à FrankOVD
Bonjour,

Après quelques corrections, mon courriel est enfin envoyé au destinataire mais une des deux pièces jointes au format pdf ($file) ne peut pas être lue par tous les destinataires (moi oui, d'autres non). QU'est-ce qui manque?

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
function sendmail($to, $from, $subject, $body, $file = NULL, $filename = NULL, $hash = NULL, $confirmer_reception = true) {
	if($hash == NULL) $random_hash = $random_hash = md5(date('r', time()));
	else $random_hash = $hash;
	$config = get_config();
 
 
	ini_set("SMTP", $config["smtp"]); 
	ini_set('sendmail_from', $from);
	$headers  = "From: Sender <".$from.">\r\nReply-To: Receiver <".$from.">\r\n";
	if($confirmer_reception == true) {
		$headers .= "Return-Receipt-To: ".$from."\r\n";
		$headers .= "Disposition-Notification-To: ".$from."\r\n";
	}
 
	if($file != NULL) {
		$headers .= "Content-Type: multipart/mixed; boundary=\"PHP-mixed-".$random_hash."\"";
		$logo = chunk_split(base64_encode(file_get_contents("../img/logo_couleur.png")));
		ob_start();
		print("--PHP-mixed-".$random_hash."\r\n"); 
		print("Content-Type: multipart/alternative; boundary=\"PHP-alt-".$random_hash."\"\r\n\r\n");
		print("--PHP-alt-".$random_hash ."\r\n");
		print("Content-Type: text/HTML; charset=\"iso-8859-1\"\r\n");
		print("Content-Transfer-Encoding: 7bit\r\n\r\n");
		print($body."\r\n");
		print("--PHP-alt-".$random_hash."--\r\n\r\n");
 
		if($filename != NULL) { 
	  	$attachment = chunk_split(base64_encode(file_get_contents($file)));
			print("--PHP-mixed-".$random_hash."\r\n");
			print("Content-Type: application/pdf; name=\"".basename($filename).".pdf\"\r\n");
			print("Content-Transfer-Encoding: base64 \r\n");
			print("Content-Disposition: attachment \r\n\r\n");
			print($attachment."\r\n\r\n");
			//print("--PHP-alt-".$random_hash."--\r\n");
		}
 
		print("--PHP-mixed-".$random_hash."\r\n");
		print("Content-Type: image/png; name=\"logo.png\"\r\n");
		print("Content-Transfer-Encoding: base64 \r\n");
		print("Content-Disposition: attachment \r\n\r\n");
		print($logo."\r\n\r\n");
		print("--PHP-mixed-".$random_hash."--\r\n");
		$body = ob_get_clean();
	}
	else $headers .= "Content-Type: text/HTML; boundary=\"PHP-alt-".$random_hash."\"";
	return mail($to, $subject, $body, $headers);
}
__________________
http://www.overdrunk.net

Pensez à la balise
FrankOVD est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 16/05/2011, 20h15   #3
Membre actif
 
Avatar de FrankOVD
 
Inscription : juin 2005
Messages : 407
Détails du profil
Informations forums :
Inscription : juin 2005
Messages : 407
Points : 182
Points : 182
Envoyer un message via MSN à FrankOVD
Problème résolu. Merci quand mê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
function sendmail($to, $from, $subject, $body, $file = NULL, $filename = NULL, $hash = NULL, $confirmer_reception = true) {
	if($hash == NULL) $random_hash = $random_hash = md5(date('r', time()));
	else $random_hash = $hash;
	$config = get_config();
 
 
	ini_set("SMTP", $config["smtp"]); 
	ini_set('sendmail_from', $from);
	$headers  = "From: Sender <".$from.">\r\nReply-To: Receiver <".$from.">\r\n";
	if($confirmer_reception == true) {
		$headers .= "Return-Receipt-To: ".$from."\r\n";
		$headers .= "Disposition-Notification-To: ".$from."\r\n";
	}
 
	if($file != NULL) {
		$headers .= "Content-Type: multipart/mixed; boundary=\"PHP-mixed-".$random_hash."\"";
		$logo = chunk_split(base64_encode(file_get_contents("../img/logo_couleur.png")));
		ob_start();
		print("--PHP-mixed-".$random_hash."\r\n"); 
		print("Content-Type: multipart/alternative; boundary=\"PHP-mixed-".$random_hash."\"\r\n\r\n");
		print("--PHP-mixed-".$random_hash ."\r\n");
		print("Content-Type: text/HTML; charset=\"iso-8859-1\"\r\n");
		print("Content-Transfer-Encoding: 7bit\r\n\r\n");
		print($body."\r\n");
		print("--PHP-mixed-".$random_hash."--\r\n\r\n");
 
		if($filename != NULL) { 
	  	$attachment = chunk_split(base64_encode(file_get_contents($file)));
			print("--PHP-mixed-".$random_hash."\r\n");
			print("Content-Type: application/pdf; name=\"".basename($filename).".pdf\"\r\n");
			print("Content-Transfer-Encoding: base64 \r\n");
			print("Content-Disposition: attachment \r\n\r\n");
			print($attachment."\r\n\r\n");
			//print("--PHP-alt-".$random_hash."--\r\n");
		}
 
		print("--PHP-mixed-".$random_hash."\r\n");
		print("Content-Type: image/png; name=\"logo.png\"\r\n");
		print("Content-Transfer-Encoding: base64 \r\n");
		print("Content-Disposition: attachment \r\n\r\n");
		print($logo."\r\n\r\n");
		print("--PHP-mixed-".$random_hash."--\r\n");
		$body = ob_get_clean();
	}
	else $headers .= "Content-Type: text/HTML; boundary=\"PHP-alt-".$random_hash."\"";
	return mail($to, $subject, $body, $headers);
}
__________________
http://www.overdrunk.net

Pensez à la balise
FrankOVD est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 12h07.


 
 
 
 
Partenaires

Hébergement Web