Bug #16033 [Fbk->Bgs]: PDF attachments not getting through

From: Date: Tue, 31 Mar 2009 17:41:50 +0000
Subject: Bug #16033 [Fbk->Bgs]: PDF attachments not getting through
References: 1  Groups: php.pear.bugs 
Request: Send a blank email to pear-bugs+get-286@lists.php.net to get a copy of this message
Edit report at http://pear.php.net/bugs/bug.php?id=16033&edit=1 ID: 16033 Updated by: till@php.net Reported By: ken at linux dot ie Summary: PDF attachments not getting through -Status: Feedback +Status: Bogus Type: Bug Package: Mail_Queue Operating System: Ubuntu 8.10 Package Version: 1.2.2 PHP Version: 5.2.5 -Assigned To: +Assigned To: till Roadmap Versions: New Comment: -Status: Feedback +Status: Bogus -Assigned To: +Assigned To: till Thanks for the heads up! Previous Comments: ------------------------------------------------------------------------ [2009-03-31 17:09:56] kguest I eventually traced this to a "Notice: unserialize(): Error at offset 2 of 65535 bytes in /usr/share/php/Mail/Queue/Container/mdb2.php on line 191" message. The blob datatype I had set for the body field was not big enough - I needed to change it to longblob: mysql> alter table mail_queue change body body longblob; hazarding a guess; the mime encoding of the file plus ancillary data pushed the size over the limits of the blob datatype. So, remember folks, always make sure the fields in your database are [more than] large enough for the data going in. d'oh! ------------------------------------------------------------------------ [2009-03-20 16:30:46] kguest Dear Till, The mimetype determined for the PDF was determined to be "application/pdf" and I can confirm the equivalent mails sent with PDF attachments via PEAR::Mail did work perfectly fine. They were retrieved by both Thunderbird and Evolution email clients and those attachments were saved to the local filesystem and displayed without a glitch. x Ken ------------------------------------------------------------------------ [2009-03-20 15:35:21] till -Status: Open +Status: Feedback Dear Ken, :D can you verify that the content-type returned for the PDF is correct? Also, just to double-check -- did attaching PDFs work with PEAR::Mail on your system? Best regards, Till ------------------------------------------------------------------------ [2009-03-13 14:50:48] kguest Description: ------------ Emails stored with PDF attachments are not received properly. gifs and jpegs are. Attached gifs & jpegs are received and displayed fine by the email client - but no indication of PDF being included in the email received. This is using the same schema as given in the tutorial - but changing the body field to a blob. Test PDF is approx 591K in size. I amended the code to not use Mail_Queue but the Mail package instead to determine where the problem lies - and those tests worked fine with the result of attached PDFs being received without error. Test code is as below. A 'cleansed' version of the debug output (simple search & replaces to protect the innocent re host & address details), from the conversation with the mail server, is as follows: DEBUG: Recv: 220 mail.example.com ESMTP Postfix (Debian/GNU) DEBUG: Send: EHLO localhost DEBUG: Recv: 250-mail.example.com DEBUG: Recv: 250-PIPELINING DEBUG: Recv: 250-SIZE 10240000 DEBUG: Recv: 250-VRFY DEBUG: Recv: 250-ETRN DEBUG: Recv: 250-STARTTLS DEBUG: Recv: 250-ENHANCEDSTATUSCODES DEBUG: Recv: 250-8BITMIME DEBUG: Recv: 250 DSN DEBUG: Send: MAIL FROM:<joe@example.com> DEBUG: Recv: 250 2.1.0 Ok DEBUG: Send: RCPT TO:<joe@example.com> DEBUG: Recv: 250 2.1.5 Ok DEBUG: Send: DATA DEBUG: Recv: 354 End data with <CR><LF>.<CR><LF> DEBUG: Send: MIME-Version: 1.0 From: joe@example.com To: joe@example.com Subject: test subject Content-Type: multipart/mixed; boundary="=_317984f24d0a675ae6b7bc4fb850008f" . DEBUG: Recv: 250 2.0.0 Ok: queued as 9913633C30B DEBUG: Send: QUIT DEBUG: Recv: 221 2.0.0 Bye Test script: --------------- in insert.php: include 'Mail/Queue/Container/mdb2.php'; include 'Mail/Queue/Container.php'; include 'Mail/Queue.php'; define('DB_HOST', 'localhost'); define('DB_NAME', 'testdb'); define('DB_PASS', ''); define('DB_USER', 'root'); $db_options['dsn'] = 'mysqli://'.DB_USER.':'.DB_PASS.'@'.DB_HOST.'/'.DB_NAME; $db_options['mail_table'] = 'mail_queue'; $db_options['type'] = 'mdb2'; $mail_options['driver'] = 'smtp'; $mail_options['host'] = 'mail.example.com'; $mail_options['port'] = 25; $mail_options['localhost'] = 'localhost'; $mail_options['auth'] = false; $mail_options['debug'] = false; $mail_queue =& new Mail_Queue($db_options, $mail_options); $file= '/home/ken/Desktop/PHPWhitePaper.pdf'; $mimetype = mime_content_type($file); $from = 'joe@example.com'; $to = "joe@example.com"; $message = "Hi! This is test message!! :)\n{$mimetype}"; $hdrs = array( 'From' => $from, 'To' => $to, 'Subject' => "test subject" ); /* we use Mail_mime() to construct a valid mail */ $mime = new Mail_mime(); $mime->setTXTBody($message); $mime->setHTMLBody("<html><body><b>$message</b></body></html>"); $mime->addAttachment($file, $mimetype); $body = $mime->get(); $hdrs = $mime->headers($hdrs); /* Put message to queue */ $mail_queue->put($from, $to, $hdrs, $body); in flush.php: include 'Mail/Queue.php'; include 'Mail/Queue/Container.php'; include 'Mail/Queue/Container/mdb2.php'; define('DB_HOST', 'localhost'); define('DB_USER', 'root'); define('DB_PASS', ''); define('DB_NAME', 'testdb'); $db_options['type'] = 'mdb2'; $db_options['dsn'] = 'mysqli://'.DB_USER.':'.DB_PASS.'@'.DB_HOST.'/'.DB_NAME; $db_options['mail_table'] = 'mail_queue'; $mail_options['driver'] = 'smtp'; $mail_options['host'] = 'mail.example.com'; $mail_options['port'] = 25; $mail_options['localhost'] = 'localhost'; //optional Mail_smtp parameter $mail_options['auth'] = false; $mail_options['debug'] = true; /* How many mails could we send each time the script is called */ $max_amount_mails = 50; /* we use the db_options and mail_options from the config again */ $mail_queue =& new Mail_Queue($db_options, $mail_options, 0 , false); /* really sending the messages */ $dn = $mail_queue->sendMailsInQueue($max_amount_mails); if (!$dn === true) { var_dump($dn); } Expected result: ---------------- Email to which PDF is attached should be received with the attachment intact. Actual result: -------------- Viewing source of the email shows no reference to intended attachment. ------------------------------------------------------------------------ -- Edit this bug report at http://pear.php.net/bugs/bug.php?id=16033&edit=1

« previous php.pear.bugs (#286) next »