Hello,

I have some trouble with sending emails with an MS word attachment. I let
fill a word document from my php website. When it is finished with filling
the information, the document is saved on the webserver and the word
application will be closed by the website. So far so good. Now I want to
send this created document to the user via the mail function. If I send an
email without the attachment it works great. So there is no error with the
SMTP server. But when I send this email with the attachment, the webserver
breaks down and I receive no email. I can't see the error in the code. So
perhaps someone can help me.

Here is the code:

....
$word->StatusBar = "Fertig!"; // Statusbar Ausgabe
$word->ActiveDocument->SaveAs("d:\wwwRoot\Lieferprogramm\ProductPortfolio.doc");
//$word->ActiveDocument->Save();
$word->Documents->Close();
$word->Quit();
$word = null;
$Empfaenger = "[EMAIL PROTECTED]";
$Betreff = "Product Portfolio";
//$Dateiname = "d:\\wwwRoot\\Lieferprogram\\ProductPortfolio.doc";
$Dateiname = "ProductPortfolio.doc";
$DateinameMail = "ProductPortfolio.doc";
$Header = "From: [EMAIL PROTECTED] <[EMAIL PROTECTED]>";
$Trenner = md5(uniqid(time()));
$Header .= "\n";
$Header .= "MIME-Version: 1.0";
$Header .= "\n";
$Header .= "Content-Type: multipart/mixed; boundary=\"$Trenner\"";
$Header .= "\n\n";
$Header .= "This is a multi-part message in MIME format";
$Header .= "\n";
$Header .= "--$Trenner";
$Header .= "\n";
$Header .= "Content-Type: text/plain; charset=\"iso-8859-9\"";
$Header .= "\n";
$Header .= "Content-Transfer-Encoding: 8bit";
$Header .= "\n\n";
$Header .= "Product Portfolio";
$Header .= "\n";
$Header .= "--$Trenner";
$Header .= "\n";
$Header .= "Content-Type: application/msword; name=\"$DateinameMail\"";
$Header .= "\n";
$Header .= "Content-Transfer-Encoding: base64";
$Header .= "\n";
$Header .= "Content-Disposition: attachment; filename=\"$DateinameMail\"";
$Header .= "\n\n";
$Dateiinhalt = fread(fopen($Dateiname, "r"), filesize($Dateiname));
$Header .= chunk_split(base64_encode($Dateiinhalt));
$Header .= "\n";
$Header .= "--$Trenner--";
mail($Empfaenger, $Betreff, "", $Header);
....



Thanks in advance.

Dennis

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to