Personne na de solution ?

j'utilise la classe suivante :
<?php
class simplemail {
var $recipient;
var $subject;
var $hfrom;
var $headers;
var $hbcc;
var $hcc;
var $text;
var $html;
var $attachement;
var $htmlattachement;
var $error_log;
function simplemail() {
$this -> attachement = array();
$this -> htmlattachement = array();
}
function checkaddress($address) {
if ( preg_match("`[0-9a-zA-Z\.\-_]+@[0-9a-zA-z\-]{3,}\.[a-z]{2,4}`" , $address ) )
{ return TRUE; }
else
{ $this->error_log.="l'adresse $address est invalide\n"; return FALSE; }
}
function checkname($name) {
if ( preg_match("`[0-9a-zA-Z\.\-_ ]*`" , $name ) )
{ return TRUE; }
else
{ $this->error_log.=" le pseudo $name est invalide\n"; return FALSE; }
}
function makenameplusaddress($address,$name) {
if ( !$this->checkaddress($address) ) return FALSE;
if ( !$this->checkname($name) ) return FALSE;
if ( empty($name) ) { return $address; }
else { $tmp=$name." <".$address.">"; return $tmp; }
}
function addrecipient($newrecipient,$name='') {
$tmp=$this->makenameplusaddress($newrecipient,$name);
if ( !$tmp ) { $this->error_log.=" To: error\n"; return FALSE; }
if ( !empty($this->recipient) ) $this->recipient.= ",";
$this->recipient.= $tmp;
return TRUE;
}
function addbcc($bcc,$name='') {
$tmp=$this->makenameplusaddress($bcc,$name);
if ( !$tmp ) { $this->error_log.=" Bcc: error\n"; return FALSE; }
if ( !empty($this->hbcc)) $this->hbcc.= ",";
$this->hbcc.= $tmp;
return TRUE;
}
function addcc($cc,$name='') {
$tmp=$this->makenameplusaddress($cc,$name);
if ( !$tmp ) { $this->error_log.=" Cc: error\n"; return FALSE; }
if (!empty($this->hcc)) $this->hcc.= ",";
$this->hcc.= $tmp;
return TRUE;
}
function addsubject($subject) {
if (!empty($subject)) $this->subject= $subject;
}
function addfrom($from,$name='') {
$tmp=$this->makenameplusaddress($from,$name);
if ( !$tmp ) { $this->error_log.=" From: error\n"; return FALSE; }
$this->hfrom = $tmp;
return TRUE;
}
function addreturnpath($return) {
$tmp=$this->makenameplusaddress($return,'');
if ( !$tmp ) { $this->error_log.=" Return-Path: error\n"; return FALSE; }
$this->returnpath = $return;
return TRUE;
}
function addreplyto($replyto) {
$tmp=$this->makenameplusaddress($replyto,'');
if ( !$tmp ) { $this->error_log.=" Reply-To: error\n"; return FALSE; }
$this->returnpath = $tmp;
return TRUE;
}
// les attachements
function addattachement($filename) {
array_push ( $this -> attachement , array ( 'filename'=> $filename ) );
}
// les attachements html
function addhtmlattachement($filename,$cid='',$contenttype='') {
array_push ( $this -> htmlattachement , array ( 'filename'=>$filename , 'cid'=>$cid , 'contenttype'=>$contenttype ) );
}
function sendmail(){
if ( empty($this->recipient) ) { $this->error_log.="destinataire manquant\n"; return FALSE; }
if ( empty($this->subject) ) { $this->error_log.="sujet manquant\n"; return FALSE; }
if ( !empty($this->hfrom) ) $headers.= "From: ".$this->hfrom."\n";
if ( !empty($this->returnpath) ) $headers.= "Return-Path: ".$this->returnpath."\n";
if ( !empty($this->replyto) ) $headers.= "Reply-To: ".$this->replyto."\n";
// if ( !empty($this->hcc) ) $headers.= "Cc: ".$this->hcc."\n";
// if ( !empty($this->hbcc) ) $headers.= "Bcc: ".$this->hbcc."\n";
$headers .="MIME-Version: 1.0\n";
//echo $headers;
if ( !$this->html && $this->text ) {
$B1B="----=_001";
$headers.="Content-Type: multipart/mixed;\n\t boundary=\"".$B1B."\"\n";
if ( !empty($this->hcc) ) $headers.= "Cc: ".$this->hcc."\n";
if ( !empty($this->hbcc) ) $headers.= "Bcc: ".$this->hbcc."\n";
//Messages start with text/html alternatives in OB
$message ="This is a multi-part message in MIME format.\n";
$message.="\n--".$B1B."\n";
$message.="Content-Type: text/plain; charset=\"iso-8859-1\"\n";
$message.="Content-Transfer-Encoding: quoted-printable\n\n";
// plaintext goes here
$message.=$this->text."\n\n";
if ( !empty($this->attachement) ) {
foreach($this->attachement as $AttmFile){
$patharray = explode ("/", $AttmFile['filename']);
$FileName=$patharray[count($patharray)-1];
$message.= "\n--".$B1B."\n";
$message.="Content-Type: application/octetstream;\n name=\"".$FileName."\"\n";
$message.="Content-Transfer-Encoding: base64\n";
$message.="Content-Disposition: attachment;\n filename=\"".$FileName."\"\n\n";
$fd=fopen ($AttmFile['filename'], "rb");
$FileContent=@fread($fd,filesize($AttmFile['filename']));
fclose ($fd);
$FileContent=chunk_split(base64_encode($FileContent));
$message.=$FileContent;
$message.="\n\n";
}
}
//message ends
$message.="\n--".$B1B."--\n";
}
elseif ( $this->html ) {
$B1B="----=_001";
$B2B="----=_002";
$B3B="----=_003";
if ( !$this->text ) { $this->text="HTML only!"; }
$headers.="Content-Type: multipart/mixed;\n\t boundary=\"".$B1B."\"\n";
if ( !empty($this->hcc) ) $headers.= "Cc: ".$this->hcc."\n";
if ( !empty($this->hbcc) ) $headers.= "Bcc: ".$this->hbcc."\n";
//Messages start with text/html alternatives in OB
$message ="This is a multi-part message in MIME format.\n";
$message.="\n--".$B1B."\n";
$message.="Content-Type: multipart/related;\n\t boundary=\"".$B2B."\"\n\n";
//plaintext section
$message.="\n--".$B2B."\n";
$message.="Content-Type: multipart/alternative;\n\t boundary=\"".$B3B."\"\n\n";
//plaintext section
$message.="\n--".$B3B."\n";
$message.="Content-Type: text/plain; charset=\"iso-8859-1\"\n";
$message.="Content-Transfer-Encoding: quoted-printable\n\n";
// plaintext goes here
$message.=$this->text."\n\n";
// html section
$message.="\n--".$B3B."\n";
$message.="Content-Type: text/html; charset=\"iso-8859-1\"\n";
$message.="Content-Transfer-Encoding: base64\n\n";
// html goes here
$message.=chunk_split(base64_encode($this->html))."\n\n";
// end of text
$message.="\n--".$B3B."--\n";
// attachments html
if ( !empty($this->htmlattachement) ) {
foreach($this->htmlattachement as $AttmFile){
$patharray = explode ("/", $AttmFile['filename']);
$FileName=$patharray[count($patharray)-1];
$message.= "\n--".$B2B."\n";
$message.="Content-Type: {$AttmFile['contenttype']};\n name=\"".$FileName."\"\n";
$message.="Content-Transfer-Encoding: base64\n";
$message.="Content-ID: <{$AttmFile['cid']}>\n";
$message.="Content-Disposition: inline;\n filename=\"".$FileName."\"\n\n";
$fd=fopen ($AttmFile['filename'], "rb");
$FileContent=fread($fd,filesize($AttmFile['filename']));
fclose ($fd);
$FileContent=chunk_split(base64_encode($FileContent));
$message.=$FileContent;
$message.="\n\n";
}
}
//html ends
$message.="\n--".$B2B."--\n";
if ( !empty($this->attachement) ) {
foreach($this->attachement as $AttmFile){
$patharray = explode ("/", $AttmFile['filename']);
$FileName=$patharray[count($patharray)-1];
$message.= "\n--".$B1B."\n";
$message.="Content-Type: application/octetstream;\n name=\"".$FileName."\"\n";
$message.="Content-Transfer-Encoding: base64\n";
$message.="Content-Disposition: attachment;\n filename=\"".$FileName."\"\n\n";
$fd=fopen ($AttmFile['filename'], "rb");
$FileContent=fread($fd,filesize($AttmFile['filename']));
fclose ($fd);
$FileContent=chunk_split(base64_encode($FileContent));
$message.=$FileContent;
$message.="\n\n";
}
}
//message ends
$message.="\n--".$B1B."--\n";
}
$recipient=$this->recipient;
$subject=$this->subject;
if ( @mail($recipient, $subject, $message, $headers) ) { return TRUE; } else { return FALSE; }
}
}
?>
ensuite dans ma page voila ce que je fais
// Parcours du repertoire local
foreach( glob("*.pdf") as $nom_bordereau )
{
$compteur++;
//recuperation du code asso pour vérification email
$codasso = substr($nom_bordereau,24,5);
$codasso = $codasso.'20';
// connexion à la base pour récupérer l'email de l'asso correspondante
$c = @mysql_connect("localhost","utilisateur","motdepasse") or die("connection impossible");
@mysql_select_db("mabase",$c) or die("selection impossible");
if($p = @mysql_query("SELECT EMAIL FROM ASSOCIATION2 WHERE CODASSO='".$codasso."'",$c))
{
$r = @mysql_fetch_assoc($p);
$mail_asso = $r[EMAIL];
}
// si adresse mail envoi du message sinon avertissement
if ( $mail_asso != '')
{
// préparation du mail spécifique
$mail = new simplemail;
$mail -> addrecipient($mail_asso);
$mail -> addfrom('[email protected]','xxxxxxxxxxx');
$mail -> addsubject('envoi bordereau Heures PEC - '.$codasso);
// le message texte
$mail -> text = "Bonjour\r\nVeuillez trouver ci-joint le bordereau des heures de Prise en charge pour votre association\r\n";
// on ajoute le fichier en pièce jointe
$mail -> addattachement ($nom_bordereau);
// envoi du message
$heure = date("H:i:s");
if ( $mail -> sendmail() )
{
$message .= $heure." : mail envoyé à l'asso ".$codasso." à l'adresse suivante : ".$mail_asso."\r";
}
else
{
$mail-> error_log;
$erreurmail++;
$message .= $heure." : erreur lors de l'envoi ".$mail." pour l'asso ".$codasso." avec l'adresse ".$mail_asso."\r";
}
}
else
{
$heure = date("H:i:s");
$message .= $heure." : pas de mail pour l'association : ".$codasso."\r";
$erreur++;
}
}
....et c'est avec cette adresse '
[email protected]' que ça plante ! toutes les autres fonctionnent , mais elles sont toutes comme ça
[email protected],
[email protected] etc.....
Personne na de solution ? :cry: j'utilise la classe suivante :
[php]<?php
class simplemail {
var $recipient;
var $subject;
var $hfrom;
var $headers;
var $hbcc;
var $hcc;
var $text;
var $html;
var $attachement;
var $htmlattachement;
var $error_log;
function simplemail() {
$this -> attachement = array();
$this -> htmlattachement = array();
}
function checkaddress($address) {
if ( preg_match("`[0-9a-zA-Z\.\-_]+@[0-9a-zA-z\-]{3,}\.[a-z]{2,4}`" , $address ) )
{ return TRUE; }
else
{ $this->error_log.="l'adresse $address est invalide\n"; return FALSE; }
}
function checkname($name) {
if ( preg_match("`[0-9a-zA-Z\.\-_ ]*`" , $name ) )
{ return TRUE; }
else
{ $this->error_log.=" le pseudo $name est invalide\n"; return FALSE; }
}
function makenameplusaddress($address,$name) {
if ( !$this->checkaddress($address) ) return FALSE;
if ( !$this->checkname($name) ) return FALSE;
if ( empty($name) ) { return $address; }
else { $tmp=$name." <".$address.">"; return $tmp; }
}
function addrecipient($newrecipient,$name='') {
$tmp=$this->makenameplusaddress($newrecipient,$name);
if ( !$tmp ) { $this->error_log.=" To: error\n"; return FALSE; }
if ( !empty($this->recipient) ) $this->recipient.= ",";
$this->recipient.= $tmp;
return TRUE;
}
function addbcc($bcc,$name='') {
$tmp=$this->makenameplusaddress($bcc,$name);
if ( !$tmp ) { $this->error_log.=" Bcc: error\n"; return FALSE; }
if ( !empty($this->hbcc)) $this->hbcc.= ",";
$this->hbcc.= $tmp;
return TRUE;
}
function addcc($cc,$name='') {
$tmp=$this->makenameplusaddress($cc,$name);
if ( !$tmp ) { $this->error_log.=" Cc: error\n"; return FALSE; }
if (!empty($this->hcc)) $this->hcc.= ",";
$this->hcc.= $tmp;
return TRUE;
}
function addsubject($subject) {
if (!empty($subject)) $this->subject= $subject;
}
function addfrom($from,$name='') {
$tmp=$this->makenameplusaddress($from,$name);
if ( !$tmp ) { $this->error_log.=" From: error\n"; return FALSE; }
$this->hfrom = $tmp;
return TRUE;
}
function addreturnpath($return) {
$tmp=$this->makenameplusaddress($return,'');
if ( !$tmp ) { $this->error_log.=" Return-Path: error\n"; return FALSE; }
$this->returnpath = $return;
return TRUE;
}
function addreplyto($replyto) {
$tmp=$this->makenameplusaddress($replyto,'');
if ( !$tmp ) { $this->error_log.=" Reply-To: error\n"; return FALSE; }
$this->returnpath = $tmp;
return TRUE;
}
// les attachements
function addattachement($filename) {
array_push ( $this -> attachement , array ( 'filename'=> $filename ) );
}
// les attachements html
function addhtmlattachement($filename,$cid='',$contenttype='') {
array_push ( $this -> htmlattachement , array ( 'filename'=>$filename , 'cid'=>$cid , 'contenttype'=>$contenttype ) );
}
function sendmail(){
if ( empty($this->recipient) ) { $this->error_log.="destinataire manquant\n"; return FALSE; }
if ( empty($this->subject) ) { $this->error_log.="sujet manquant\n"; return FALSE; }
if ( !empty($this->hfrom) ) $headers.= "From: ".$this->hfrom."\n";
if ( !empty($this->returnpath) ) $headers.= "Return-Path: ".$this->returnpath."\n";
if ( !empty($this->replyto) ) $headers.= "Reply-To: ".$this->replyto."\n";
// if ( !empty($this->hcc) ) $headers.= "Cc: ".$this->hcc."\n";
// if ( !empty($this->hbcc) ) $headers.= "Bcc: ".$this->hbcc."\n";
$headers .="MIME-Version: 1.0\n";
//echo $headers;
if ( !$this->html && $this->text ) {
$B1B="----=_001";
$headers.="Content-Type: multipart/mixed;\n\t boundary=\"".$B1B."\"\n";
if ( !empty($this->hcc) ) $headers.= "Cc: ".$this->hcc."\n";
if ( !empty($this->hbcc) ) $headers.= "Bcc: ".$this->hbcc."\n";
//Messages start with text/html alternatives in OB
$message ="This is a multi-part message in MIME format.\n";
$message.="\n--".$B1B."\n";
$message.="Content-Type: text/plain; charset=\"iso-8859-1\"\n";
$message.="Content-Transfer-Encoding: quoted-printable\n\n";
// plaintext goes here
$message.=$this->text."\n\n";
if ( !empty($this->attachement) ) {
foreach($this->attachement as $AttmFile){
$patharray = explode ("/", $AttmFile['filename']);
$FileName=$patharray[count($patharray)-1];
$message.= "\n--".$B1B."\n";
$message.="Content-Type: application/octetstream;\n name=\"".$FileName."\"\n";
$message.="Content-Transfer-Encoding: base64\n";
$message.="Content-Disposition: attachment;\n filename=\"".$FileName."\"\n\n";
$fd=fopen ($AttmFile['filename'], "rb");
$FileContent=@fread($fd,filesize($AttmFile['filename']));
fclose ($fd);
$FileContent=chunk_split(base64_encode($FileContent));
$message.=$FileContent;
$message.="\n\n";
}
}
//message ends
$message.="\n--".$B1B."--\n";
}
elseif ( $this->html ) {
$B1B="----=_001";
$B2B="----=_002";
$B3B="----=_003";
if ( !$this->text ) { $this->text="HTML only!"; }
$headers.="Content-Type: multipart/mixed;\n\t boundary=\"".$B1B."\"\n";
if ( !empty($this->hcc) ) $headers.= "Cc: ".$this->hcc."\n";
if ( !empty($this->hbcc) ) $headers.= "Bcc: ".$this->hbcc."\n";
//Messages start with text/html alternatives in OB
$message ="This is a multi-part message in MIME format.\n";
$message.="\n--".$B1B."\n";
$message.="Content-Type: multipart/related;\n\t boundary=\"".$B2B."\"\n\n";
//plaintext section
$message.="\n--".$B2B."\n";
$message.="Content-Type: multipart/alternative;\n\t boundary=\"".$B3B."\"\n\n";
//plaintext section
$message.="\n--".$B3B."\n";
$message.="Content-Type: text/plain; charset=\"iso-8859-1\"\n";
$message.="Content-Transfer-Encoding: quoted-printable\n\n";
// plaintext goes here
$message.=$this->text."\n\n";
// html section
$message.="\n--".$B3B."\n";
$message.="Content-Type: text/html; charset=\"iso-8859-1\"\n";
$message.="Content-Transfer-Encoding: base64\n\n";
// html goes here
$message.=chunk_split(base64_encode($this->html))."\n\n";
// end of text
$message.="\n--".$B3B."--\n";
// attachments html
if ( !empty($this->htmlattachement) ) {
foreach($this->htmlattachement as $AttmFile){
$patharray = explode ("/", $AttmFile['filename']);
$FileName=$patharray[count($patharray)-1];
$message.= "\n--".$B2B."\n";
$message.="Content-Type: {$AttmFile['contenttype']};\n name=\"".$FileName."\"\n";
$message.="Content-Transfer-Encoding: base64\n";
$message.="Content-ID: <{$AttmFile['cid']}>\n";
$message.="Content-Disposition: inline;\n filename=\"".$FileName."\"\n\n";
$fd=fopen ($AttmFile['filename'], "rb");
$FileContent=fread($fd,filesize($AttmFile['filename']));
fclose ($fd);
$FileContent=chunk_split(base64_encode($FileContent));
$message.=$FileContent;
$message.="\n\n";
}
}
//html ends
$message.="\n--".$B2B."--\n";
if ( !empty($this->attachement) ) {
foreach($this->attachement as $AttmFile){
$patharray = explode ("/", $AttmFile['filename']);
$FileName=$patharray[count($patharray)-1];
$message.= "\n--".$B1B."\n";
$message.="Content-Type: application/octetstream;\n name=\"".$FileName."\"\n";
$message.="Content-Transfer-Encoding: base64\n";
$message.="Content-Disposition: attachment;\n filename=\"".$FileName."\"\n\n";
$fd=fopen ($AttmFile['filename'], "rb");
$FileContent=fread($fd,filesize($AttmFile['filename']));
fclose ($fd);
$FileContent=chunk_split(base64_encode($FileContent));
$message.=$FileContent;
$message.="\n\n";
}
}
//message ends
$message.="\n--".$B1B."--\n";
}
$recipient=$this->recipient;
$subject=$this->subject;
if ( @mail($recipient, $subject, $message, $headers) ) { return TRUE; } else { return FALSE; }
}
}
?>[/php]
ensuite dans ma page voila ce que je fais[php]// Parcours du repertoire local
foreach( glob("*.pdf") as $nom_bordereau )
{
$compteur++;
//recuperation du code asso pour vérification email
$codasso = substr($nom_bordereau,24,5);
$codasso = $codasso.'20';
// connexion à la base pour récupérer l'email de l'asso correspondante
$c = @mysql_connect("localhost","utilisateur","motdepasse") or die("connection impossible");
@mysql_select_db("mabase",$c) or die("selection impossible");
if($p = @mysql_query("SELECT EMAIL FROM ASSOCIATION2 WHERE CODASSO='".$codasso."'",$c))
{
$r = @mysql_fetch_assoc($p);
$mail_asso = $r[EMAIL];
}
// si adresse mail envoi du message sinon avertissement
if ( $mail_asso != '')
{
// préparation du mail spécifique
$mail = new simplemail;
$mail -> addrecipient($mail_asso);
$mail -> addfrom('
[email protected]','xxxxxxxxxxx');
$mail -> addsubject('envoi bordereau Heures PEC - '.$codasso);
// le message texte
$mail -> text = "Bonjour\r\nVeuillez trouver ci-joint le bordereau des heures de Prise en charge pour votre association\r\n";
// on ajoute le fichier en pièce jointe
$mail -> addattachement ($nom_bordereau);
// envoi du message
$heure = date("H:i:s");
if ( $mail -> sendmail() )
{
$message .= $heure." : mail envoyé à l'asso ".$codasso." à l'adresse suivante : ".$mail_asso."\r";
}
else
{
$mail-> error_log;
$erreurmail++;
$message .= $heure." : erreur lors de l'envoi ".$mail." pour l'asso ".$codasso." avec l'adresse ".$mail_asso."\r";
}
}
else
{
$heure = date("H:i:s");
$message .= $heure." : pas de mail pour l'association : ".$codasso."\r";
$erreur++;
}
}[/php]....et c'est avec cette adresse '
[email protected]' que ça plante ! toutes les autres fonctionnent , mais elles sont toutes comme ça
[email protected],
[email protected] etc.....