Re: Problem wih mail() and attachment
| From: | chris smith | Date: | Tue, 28 Mar 2006 10:43:08 +0000 |
| Subject: | Re: Problem wih mail() and attachment | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-232725@lists.php.net to get a copy of this message | ||
On 3/27/06, Dennis N. <da_ill@web.de> wrote:
> 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 = "empfänger@domäne.com";
> $Betreff = "Product Portfolio";
> //$Dateiname = "d:\\wwwRoot\\Lieferprogram\\ProductPortfolio.doc";
> $Dateiname = "ProductPortfolio.doc";
> $DateinameMail = "ProductPortfolio.doc";
> $Header = "From: versender@domäne.com <versender@domäne.com>";
> $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));
The file doesn't go in the header, it goes in the body.
Can I ask why you're not using something like phpmailer
(http://phpmailer.sf.net) ?
--
Postgresql & php tutorials
http://www.designmagick.com/