IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

EDI, CMS, Outils, Scripts et API PHP Discussion :

Fonction d'envoi de courriel a cessé de fonctionner.


Sujet :

EDI, CMS, Outils, Scripts et API PHP

  1. #1
    Membre actif Avatar de FrankOVD
    Homme Profil pro
    Directeur des systèmes d'information
    Inscrit en
    Juin 2005
    Messages
    438
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Canada

    Informations professionnelles :
    Activité : Directeur des systèmes d'information
    Secteur : Biens de consommation

    Informations forums :
    Inscription : Juin 2005
    Messages : 438
    Points : 254
    Points
    254
    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 : Sélectionner tout - Visualiser dans une fenêtre à part
    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);
    }
    Pensez à la balise

  2. #2
    Membre actif Avatar de FrankOVD
    Homme Profil pro
    Directeur des systèmes d'information
    Inscrit en
    Juin 2005
    Messages
    438
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Canada

    Informations professionnelles :
    Activité : Directeur des systèmes d'information
    Secteur : Biens de consommation

    Informations forums :
    Inscription : Juin 2005
    Messages : 438
    Points : 254
    Points
    254
    Par défaut
    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 : Sélectionner tout - Visualiser dans une fenêtre à part
    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);
    }
    Pensez à la balise

  3. #3
    Membre actif Avatar de FrankOVD
    Homme Profil pro
    Directeur des systèmes d'information
    Inscrit en
    Juin 2005
    Messages
    438
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Canada

    Informations professionnelles :
    Activité : Directeur des systèmes d'information
    Secteur : Biens de consommation

    Informations forums :
    Inscription : Juin 2005
    Messages : 438
    Points : 254
    Points
    254
    Par défaut
    Problème résolu. Merci quand même.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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);
    }
    Pensez à la balise

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. envoi de courriel avec la fonction mail
    Par Claude Poulin dans le forum Langage
    Réponses: 0
    Dernier message: 28/02/2011, 20h56
  2. [OUTLOOK] Envoi de courriel automatique
    Par NicoNours dans le forum Outlook
    Réponses: 2
    Dernier message: 27/07/2006, 22h19
  3. [Upload] Fonction is_uploaded_file + envois multiples
    Par dj-julio dans le forum Langage
    Réponses: 7
    Dernier message: 21/12/2005, 14h50
  4. [MAPI] Envoi de courriels par scripts
    Par NicoNours dans le forum Windows
    Réponses: 3
    Dernier message: 26/05/2005, 12h01
  5. Problème avec fonction d'envoie de mail
    Par zyg dans le forum Réseau/Web
    Réponses: 1
    Dernier message: 23/02/2005, 08h48

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo