RE: [PEAR] Problem Mailing PDF using Mime

From: Date: Fri, 09 Sep 2005 16:38:43 +0000
Subject: RE: [PEAR] Problem Mailing PDF using Mime
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-20885@lists.php.net to get a copy of this message
Here are the headers and part of the body produced by the script... From root@sendfax.mycompany.com Fri Sep 9 12:32:56 2005 Return-Path: <root@sendfax.mycompany.com> Received: from sendfax.mycompany.com (cg.mycompany.com [xx.xxx.xx.xx]) by www.myhome.com (8.12.10/8.11.2) with ESMTP id j89GWtXT031387 for <bdrexler@myhome.com>; Fri, 9 Sep 2005 12:32:55 -0400 Received: by sendfax.mycompany.com (Postfix, from userid 0) id 5841424FE4; Fri, 9 Sep 2005 12:34:40 -0400 (EDT) To: bdrexler@myhome.com Subject: This is a test email MIME-Version: 1.0 From: bdrexler@mycompany.com Content-Type: multipart/mixed; boundary="=_f2c101084b996bc089739280c1782d15" Message-Id: <20050909163440.5841424FE4@sendfax.mycompany.com> Date: Fri, 9 Sep 2005 12:34:40 -0400 (EDT) --=_f2c101084b996bc089739280c1782d15^M Content-Type: multipart/alternative;^M boundary="=_c3e7147a2445ae6c2386a4397d92bc56"^M ^M --=_c3e7147a2445ae6c2386a4397d92bc56^M Content-Type: text/plain; charset="ISO-8859-1"^M Content-Transfer-Encoding: 7bit^M ^M Dear John, This is a fake email, I hope you enjoy it. >From Jane.^M --=_c3e7147a2445ae6c2386a4397d92bc56^M Content-Type: text/html; charset="ISO-8859-1"^M Content-Transfer-Encoding: quoted-printable^M ^M <html>^M <body bgcolor=3D"#ffffff">^M <p align=3D"center">^M <b>Hello World!</b>^M </p>^M </body>^M </html>^M --=_c3e7147a2445ae6c2386a4397d92bc56--^M --=_f2c101084b996bc089739280c1782d15^M Content-Type: application/octet-stream^M Content-Transfer-Encoding: base64^M Content-Disposition: attachment; filename="Quote14-63344.pdf"^M ^M JVBERi0xLjIKJcfsj6IKNiAwIG9iago8PC9MZW5ndGggNyAwIFIvRmlsdGVyIC9GbGF0ZURlY29k ^M ZT4+CnN0cmVhbQp4nO1da5PctpX93r+id52qdVKeNgECBOlP8UMpp/KypNn1e....REST OF THE PDF FILE -----Original Message----- From: Klaus Guenther [mailto:klaus@capitalfocus.org] Sent: Friday, September 09, 2005 12:11 PM To: bdrexler@saginawcontrol.com Cc: pear-general@lists.php.net Subject: Re: [PEAR] Problem Mailing PDF using Mime Sorry to reply on top, but it sounds like you may be lacking a linefeed or two at the top of the generated email (below the headers, maybe). Do a var_dump and see. Or something like that. I think it is exclusively a linefeed issue. Klaus On 9/9/2005 6:07 PM, Brian Drexler spake the following words: >Not sure if this matters, but this machine is using Postfix for the MTA >instead of Sendmail... > >-----Original Message----- >From: Brian Drexler [mailto:bdrexler@saginawcontrol.com] >Sent: Friday, September 09, 2005 11:06 AM >To: pear-general@lists.php.net >Subject: [PEAR] Problem Mailing PDF using Mime > >Ok, here's my issue. I'm sending a mail message with a PDF attachment using >a script I wrote probably a year or two ago. It worked fine on my RedHat >6.2 machine running PHP version 4.3.11. Now I'm running SUSE 9.1 with PHP >4.4.0. If I send the e-mail to anyone using Outlook/Mozilla Thunderbird for >a client it works fine, but when I try sending it to my gmail account for >instance, it mashes all the headers and everything into the body of the >message and my PDF becomes text in the body of the message. Anyone have any >ideas? Here is basically the script I'm using with a default PEAR/Mime/Mail >configuration. > > > ><?php > > require_once('/usr/local/lib/php/Mail.php'); // These two files are >par > >t of Pear, > > require_once('/usr/local/lib/php/Mail/mime.php'); // and are required >for th > >e Mail_Mime class > > > > $to = "myaddress@gmail.com"; > > $from = "myaddress@mywork.com"; > > $subject = "This is a test email"; > > $attachment = "/tmp/Quote14-63344.pdf"; > > > > // Next we must build an array of email headers for the email. > > // This is structured slightly differently to the mail() function. > > // The array key is the header name. Remember that subject > > // is a header too! > > $headers = array('From' => $from, > > 'Subject' => $subject); > > > > // Here we create the plaintext version of the email to be sent > > $textMessage = "Dear John,\n\nThis is a fake email, I hope you enjoy >it.\n\n > >>From Jane."; > > > > // Here we create the HTML version of the email to be send, using > > // the heredoc syntax > > $htmlMessage = <<<EOF > ><html> > > <body bgcolor="#ffffff"> > > <p align="center"> > > <b>Hello World!</b> > > </p> > > </body> > ></html> > >EOF; > > > > $mime = new Mail_Mime(); > > // create a new instance of the Mail_Mime class > > $mime->setTxtBody($textMessage); > > // set our plaintext message > > $mime->setHtmlBody($htmlMessage); > > // set our HTML message > > $mime->addAttachment($attachment); > > // attach the file to the email > > > > $body = $mime->get(); > > // This builds the email message and returns it to $body. > > // This should only be called after all the text, html and > > // attachments are set. > > > > $hdrs = $mime->headers($headers); > > // This builds the corresponding headers for the plaintext, > > // HTML and any other required headers. It also includes > > // the headers we created earlier by passing them as an argument. > > > > $mail = &Mail::factory('mail'); > > // Creates an instance of the mail backend that we can use > > // to send the email. > > > > $mail->send($to, $hdrs, $body); > > // Send our email, according to the address in $to, the email > > // headers in $hdrs, and the message body in $body. > >?> > > >

« previous php.pear.general (#20885) next »