Ciao,
ho anche io un problema penso simile.. ho letto la guida (penso voi intendiate questa: http://php.html.it/articoli/leggi/91...tml-con-php/4/).. anzi in realtà la guida l'avevo usata proprio per creare il mio script.. ma ora mi trovo in difficltà e nn capisco perchè..
Ho creato uno script che prende un file .eml, lo apre, sostiuisce degli header, e lo spedisce a degli indirizzi presi da un database.
Sulla mia macchina in locale sunziona tutto alla perfezione (win + IIS come SMTP server), se invece trasporto il tutto su internet (server linux) non funziona più.. la mail che viene mandata ha nel corpo pure le intestazioni.. è tutto plain test, anche quello che dovrebbe essere HTML...
Probabilmente in quella guida c'è la soluzione la mio problema.. ma nn la vedo!
Allora.. questo è lo script:
codice:
//Analisi dei dati e dell'header
$array = explode("\n",$data);
foreach( $array as $key => $value ){
//Cerco sino a che non arrivo al boundary
if ( stristr($value,'boundary') ){
$header .= $array[$key]."\n";
unset($array[$key]);
break;
}
//Elimino l'header "from"
if ( @stristr($value,'from') ){
unset($array[$key]);
}
//Elimino l'header "subject" - se l'oggetto è stato inserito in fase di creazione della mail lo sostituisco a quello standard
if ( @stristr($value,'subject') ){
if ( @strlen($value) > 12 ){
$oggetto = @substr($value,strpos($value,':')+1);
}
unset($array[$key]);
}
else{
$header .= $array[$key]."\n";
unset($array[$key]);
}
}
//Aggiungo From e Subject all'header
$header_top .= "From: ".$from."\n";
$header_top .= "Subject: ".$oggetto."\n";
$data = implode("\n",$array);
//Invio la mail
$n_mail_blocco = 50;
while ( $record = @mysql_fetch_assoc($records) ){
$mailto = $record['mail'].',';
$n_mail = 1;
while ( ( $n_mail < $n_mail_blocco ) && ( $record = @mysql_fetch_assoc($records) ) ){
$mailto .= $record['mail'].',';
$n_mail++;
}
$mailto = substr($mailto,0,-1);
$header_bcc = 'Bcc: '.$mailto."\r\n";
if ( @mail($to,$oggetto,$data,$header_top.$header_bcc.$header) ){
$stato = 0;
}
}
}
Ed ecco un esempio di mail sbagliata:
codice:
Date: Fri, 14 Jul 2006 09:12:20 +0200
MIME-Version: 1.0
Content-Type: multipart/alternative;
boundary="----=_NextPart_000_0044_01C6A725.9EAC7A50"
X-Priority: 3
X-MSMail-Priority: Normal
X-Unsent: 1
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
This is a multi-part message in MIME format.
------=_NextPart_000_0044_01C6A725.9EAC7A50
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
cvdc
cv
dcv
cxv
-------------------------------------------------------------------------=
-------
=20
blabla
=20
blabla ::: Cell=20
blabla=20
blabla=20
------=_NextPart_000_0044_01C6A725.9EAC7A50
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2900.2180" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>cvdc</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>cv</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>dcv</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>cxv</FONT></DIV>
<DIV></DIV>
<DIV>
<HR>
=20
<DIV style=3D"TEXT-ALIGN: right">
<TABLE style=3D"FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Arial">
<TBODY>
<TR>
<TD style=3D"FONT-SIZE: 14px; TEXT-ALIGN: right" colSpan=3D2>blabla
</TD></TR>
<TR>
<TD style=3D"TEXT-ALIGN: right">blabla</TD>
<TD>::: Cell</TD></TR>
<TR>
<TD style=3D"TEXT-ALIGN: right>blabla</TD>
<TD>::: Mail</TD></TR>
<TR>
<TD style=3D"TEXT-ALIGN: right">blabla<=
/TD>
<TD>::: Web</TD></TR></TBODY></TABLE></DIV></DIV></BODY></HTML>
------=_NextPart_000_0044_01C6A725.9EAC7A50--