RESSOURCES 
 
Fonction Sendmail
Fourni par B2L 29 mai 2001
 
 


<?
if( SendMail( "me@me.com", "to@to.com", "My subject is...", "my body...", cTextFormat, cHighPriority) ) {
    // Sent correctly
}
else {
    // an error occured
}

// Sample with multiple recipients
SendMail( "me@me.com", "to@to.com, oser@oser.net", "My subject is...", "my body...", cHtmlFormat, cNormalPriority)
?>

define("cHtmlFormat","0");
define("cTextFormat","1");
define("cHighPriority","1");
define("cNormalPriority","3");
define("cLowPriority","5"); 
/*-------------------------------------------------------------------------
* Function : SendMail( $inFrom, $inDest, $inSubject, $inBody , $inPrio, $inFormat)
* Parameters :
*       Str inFrom from recipient
*       Str inDest dest recipient
*       Str inSubject message subject
*       Str inBody message body
*       int inPrio message priority : 1:Highest / 3:Normal / 5: lowest
*       int inFormat message format : 0:TEXT / 1:HTML
* Return :
*       true if OK
*       false otherwise 
* Purpose : Send email in text or html mode
* External function(s) :
*       stripslashes() - PHP 3, PHP 4
*       nl2br() - PHP 3, PHP 4
*       mail() - PHP 3, PHP 4
* Comment :
* (c)opyright B2L-CYBER/BBDO 2001
*-------------------------------------------------------------------------*/
function SendMail ($inFrom, $inDest, $inSubject, $inBody , $inPrio, $inFormat)
{
     $headers = "From: ". $inFrom . "\n";  // Initialize mail Header
     
// Set Message priority if ($inPrio!=cNormalPriority) $headers .= "X-Priority: ".$inPrio."\n";
$headers .= "Return-Path: " . $inFrom ."\n"; // Return address      $format_body = stripslashes( $inBody );      if ($inFormat==cHtmlFormat) {           $headers .= "Content-Type: text/html; charset=iso-8859-1\n"; // Type MIME           $format_body = nl2br ( $format_body );      }      $format_subject = stripslashes( $inSubject );      return mail($inDest, $format_subject, $format_body , $headers ); } //-----------End function : SendMail()------------------------------------
 
Accueil | Haut de page