I've uploaded a site to a new server and now the headers in the mail function are not working to send the required email response. This is a newly acquired site and my php knowledge is at the beginner level. I've managed to list the headers that are being sent but I can't seem to find where or why the email won't work. I'd really appreciate some help checking to see if there is an error in one of the header lines or perhaps the redirection.
When the email is sent this is what is output for the headers:
From: with domain name
Bcc: with email
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary=1220aa be3151c7827740f bbfd644047d
This is a multi-part message in MIME format
--1220aabe3151c78 27740fbbfd64404 7d
Content-Type: text/html; charset=ISO-8859-1
at the bottom of the email output the boundary is output again and
Warning: cannot modify header information - headers already sent by (output started at "the name of this file is listed here)???
I don't know where to go from here. It seems to be finding the includes file but then I get the Warning message. Should output buffering be added to the includes files? I'm not sure what headers to try and fix or comment out. I would really appreciate some help. I'm trying to figure out the importance of each header but I'm confused by what is necessary to allow the email to be sent.
Code:
<?
/*
Name: eMail
Description: Simple sending eMail in text and HTML with CC, BCC and attachment
Version: 1.0
last modified: 2004-05-14
Leave this header in this file!
*/
class eMail
{
var $to = array();
var $cc = array();
var $bcc = array();
var $attachment = array();
var $boundary = "";
var $header = "";
var $subject = "";
var $body = "";
function eMail($name,$mail)
{
$this->boundary = md5(uniqid(time()));
$this->header .= "From: $name <$mail>\n";
}
function to($mail)
{
$this->to[] = $mail;
}
function cc($mail)
{
$this->cc[] = $mail;
}
function bcc($mail)
{
$this->bcc[] = $mail;
}
function attachment($file)
{
$this->attachment[] = $file;
}
function subject($subject)
{
$this->subject = $subject;
}
function text($text)
{
$this->body = "Content-Type: text/plain; charset=ISO-8859-1\n";
// try without this $this->body .= "Content-Transfer-Encoding: 8bit\n\n";
$this->body .= $text."\n";
}
function html($html)
{
$this->body = "Content-Type: text/html; charset=ISO-8859-1\n";
//$this->body .= "Content-Transfer-Encoding: quoted-printable\n\n";
//$this->body .= "<html><body>\n".$html."\n</body></html>\n";
$this->body .= "\n".$html."\n\n";
}
function send()
{
// CC Empfänger hinzufügen
$max = count($this->cc);
if($max>0)
{
$this->header .= "Cc: ".$this->cc[0];
for($i=1;$i<$max;$i++)
{
$this->header .= ", ".$this->cc[$i];
}
$this->header .= "\n";
}
// BCC Empfänger hinzufügen
$max = count($this->bcc);
if($max>0)
{
$this->header .= "Bcc: ".$this->bcc[0];
for($i=1;$i<$max;$i++)
{
$this->header .= ", ".$this->bcc[$i];
}
$this->header .= "\n";
}
$this->header .= "MIME-Version: 1.0\n";
$this->header .= "Content-Type: multipart/mixed; boundary=$this->boundary\r\n";
$this->header .= "This is a multi-part message in MIME format\n";
$this->header .= "--$this->boundary\n";
$this->header .= $this->body;
// Attachment hinzufügen
$max = count($this->attachment);
if($max>0)
{
for($i=0;$i<$max;$i++)
{
$file = fread(fopen($this->attachment[$i], "r"), filesize($this->attachment[$i]));
$this->header .= "--".$this->boundary."\n";
$this->header .= "Content-Type: application/x-zip-compressed; name=".$this->attachment[$i]."\n";
$this->header .= "Content-Transfer-Encoding: base64\n";
$this->header .= "Content-Disposition: attachment; filename=".$this->attachment[$i]."\r\n";
$this->header .= chunk_split(base64_encode($file))."\n";
$file = "";
}
}
$this->header .= "--".$this->boundary."--\r\n";
foreach($this->to as $mail)
{
// print ("<pre>" .$this->header. "<pre>");
mail ($mail, $this->subject,"", $this->header);
}
}
}
?>
From: with domain name
Bcc: with email
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary=1220aa be3151c7827740f bbfd644047d
This is a multi-part message in MIME format
--1220aabe3151c78 27740fbbfd64404 7d
Content-Type: text/html; charset=ISO-8859-1
at the bottom of the email output the boundary is output again and
Warning: cannot modify header information - headers already sent by (output started at "the name of this file is listed here)???
I don't know where to go from here. It seems to be finding the includes file but then I get the Warning message. Should output buffering be added to the includes files? I'm not sure what headers to try and fix or comment out. I would really appreciate some help. I'm trying to figure out the importance of each header but I'm confused by what is necessary to allow the email to be sent.
Comment