PHP : Problème avec fonction mail()

Fermé
boss183 Messages postés 181 Date d'inscription lundi 7 janvier 2008 Statut Membre Dernière intervention 7 octobre 2011 - 8 juil. 2011 à 11:57
boss183 Messages postés 181 Date d'inscription lundi 7 janvier 2008 Statut Membre Dernière intervention 7 octobre 2011 - 8 juil. 2011 à 15:38
Bonjour à tous,

j'ai un problème avec ma fonction d'envoi de mail, lorsque je reçois un mail automatiquement grâce à la fonction PHP, l'adresse d'envoi est "toto@gmail.com"@localhost.localdomain en sachant que toto@gmail.com correspond à l'adresse que j'ai rentré dans ma variable "sendfrom". Je n'ai pas le problème lorsque mes scripts PHP tournent sur un serveur apache sous Windows, mais je viens de rencontrer le problème lorsqu'ils tournent sur un serveur apache sous une VM CentOS. Ci-dessous ma fonction d'envoi de mail :

// Envoi automatique du mail de notification
function Send_Mail($src, $dest, $login, $pass, $prenom, $nom)
{
	//ini_set("SMTP","192.168.98.15" );
	
	global $objnotife, $msgnotife, $objnotifd, $msgnotifd, $sendmailfrom, $replyto;
	
	$destinataire = analyse_mail($dest);
	
	if (is_array($destinataire))
	{
		$msgnotife = str_replace("[LOGIN]",$login,$msgnotife);
		$msgnotife = str_replace("[PASS]",$pass,$msgnotife);
		$msgnotife = str_replace("[DEST]",$dest,$msgnotife);
		$msgnotife = str_replace("[SRC]",$src,$msgnotife);
		$msgnotife = str_replace("[PRENOM]",$prenom,$msgnotife);
		$msgnotife = str_replace("[NOM]",$nom,$msgnotife);
		
		$msgnotifd = str_replace("[LOGIN]",$login,$msgnotifd);
		$msgnotifd = str_replace("[PASS]",$pass,$msgnotifd);
		$msgnotifd = str_replace("[DEST]",$dest,$msgnotifd);
		$msgnotifd = str_replace("[SRC]",$src,$msgnotifd);
		$msgnotifd = str_replace("[PRENOM]",$prenom,$msgnotifd);
		$msgnotifd = str_replace("[NOM]",$nom,$msgnotifd);
		
		$objnotifd = str_replace("[PRENOM]",ucwords($prenom),$objnotifd);
		$objnotifd = str_replace("[NOM]",strtoupper($nom),$objnotifd);
		
		if (mail($src, stripslashes($objnotife), "
	        <html><body>".stripslashes($msgnotife)."</body></html>
	        ", "Content-type:text/html\nFrom: $sendmailfrom\r\nReply-to:$replyto"))
		{
			$Ret=1;
			
			foreach ($destinataire as $des)
			{
				if (mail($des, stripslashes($objnotifd), "
	                        <html><body>".stripslashes($msgnotifd)."</body></html>
	                        ", "Content-type:text/html\nFrom: $sendmailfrom\r\nReply-to:$src"))

					$Ret=1;
				else
					$Ret=0;
			}
		}
		else
			$Ret=0;
	}
	else
		$Ret = 0;
	return $Ret;
}


Merci d'avance
A voir également:

2 réponses

HostOfSeraphim Messages postés 6750 Date d'inscription jeudi 2 février 2006 Statut Contributeur Dernière intervention 31 juillet 2016 1 607
8 juil. 2011 à 12:02
Je ne vois pas où $sendmailfrom est définie, dans ton script.

0
boss183 Messages postés 181 Date d'inscription lundi 7 janvier 2008 Statut Membre Dernière intervention 7 octobre 2011 17
8 juil. 2011 à 15:38
bah je la récupère ailleurs, par conter j'ai modifié ma fonction et j'ai le problème sous outlook et pas sur hotmail


if (is_array($destinataire))

	{

		$msgnotife = str_replace("[LOGIN]",$login,$msgnotife);

		$msgnotife = str_replace("[PASS]",$pass,$msgnotife);

		$msgnotife = str_replace("[DEST]",$dest,$msgnotife);

		$msgnotife = str_replace("[SRC]",$src,$msgnotife);

		$msgnotife = str_replace("[PRENOM]",$prenom,$msgnotife);

		$msgnotife = str_replace("[NOM]",$nom,$msgnotife);

		

		$msgnotifd = str_replace("[LOGIN]",$login,$msgnotifd);

		$msgnotifd = str_replace("[PASS]",$pass,$msgnotifd);

		$msgnotifd = str_replace("[DEST]",$dest,$msgnotifd);

		$msgnotifd = str_replace("[SRC]",$src,$msgnotifd);

		$msgnotifd = str_replace("[PRENOM]",$prenom,$msgnotifd);

		$msgnotifd = str_replace("[NOM]",$nom,$msgnotifd);

		

		$objnotifd = str_replace("[PRENOM]",ucwords($prenom),$objnotifd);

		$objnotifd = str_replace("[NOM]",strtoupper($nom),$objnotifd);

		$headers ="Content-type:text/html\r\n"; 
        	$headers .="From:test <\"$sendmailfrom\">\r\n";
	        $headers .="Return-Path:\"$replyto\"\r\n";
        	

		

		if (mail($src, stripslashes($objnotife), "<html><body>".stripslashes($msgnotife)."</body></html>", $headers, "-f \"$replyto\""))

		{

			$Ret=1;

			

			foreach ($destinataire as $des)

			{

				if (mail($des, stripslashes($objnotifd), "<html><body>".stripslashes($msgnotifd)."</body></html>", $headers, "-f \"$replyto\""))



					$Ret=1;

				else

					$Ret=0;

			}

		}

		else

			$Ret=0;

	}

	else

		$Ret = 0;

	return $Ret;

}
0