Gandi Wiki


You are on a question's page

Gandi Hosting
answered

Question "mail () with php", by Florence a.

www.balivilla.fr

I use mail function in php:

<?php

$to = "webmaster@pambali.com";

$subject = "Hi!";

$body = "Hi,\n\nHow are you?";

if (mail($to, $subject, $body)) {

echo("<p>Message successfully sent!</p>");

} else {

echo("<p>Message delivery failed...</p>");

}

?>

and this not work at gandi server (Message delivery failed…), please help me ASAP

thank you

Answer, by Benoit L.

Hi i am not very good in english, but i have read some thing that is : for use the Mail function the host server is obliged to have a sendmail server. I dont know how to configure that type of server sorry!

Else it may be possible to use an fai server with this function :

function envoi($donnees)

{
	
	
	$smtp =fsockopen($this->smtp,'25',$errno, $errstr, 30);
	if (!$smtp) {
   echo "ERREUR : $errno - $errstr<br />\n";
	}
	else{
	
	$envoi_mail ="HELO ".$this->site."\r\n";
	$envoi_mail.="MAIL FROM:<contact@".$this->site.">\r\n";
		foreach($this->destinataire as $dest)
		{
			$envoi_mail.="RCPT TO:<$dest>\r\n";	
		}
	$envoi_mail.="DATA\r\n";
	$envoi_mail.= "MIME-Version: 1.0 \r\n";
	$envoi_mail.= "Content-Type: text/html; charset=\"iso-8859-1\" ";
	
$envoi_mail.="Content-Transfer-Encoding: 8bit"."\r\n"; 
		
		foreach($this->destinataire as $dest)
		{
			$envoi_mail.="To:$dest\r\n" ;
		}
	include("model-mail.php");
	$envoi_mail.=".\r\n";
	$envoi_mail.="QUIT\r\n";
	
	fwrite($smtp, $envoi_mail);
	echo fread($smtp,1000);
	
	echo $envoi_mail;
	
	
	}
}

Good luck …

Last modified: 19 Jun 2008 at 11:34 by Benoit L.