A community in which webmasters can ask for help with topics such as PHP coding , MySQL , IT jobs, web design, IT security.
Current location:homephp forumphp talk in 2009 yearZend Framework: Some email users get errors when trying to open PDF attachments? - page 1
User InfoPosts
Zend Framework: Some email users get errors when trying to open PDF attachments?#1
I(m having a strange problem and not sure how to troubleshoot it. I have created a script in one of my Zend Framework controllers that allows an administrator to log in, upload a PDF, and send as an attachment to everyone subscribed to the mailing list. The problem is that some users report that they are unable to open the PDF attachment, that the file is corrupt. I think this is only happening to AOL users, but I(m not positive. Have you encountered this problem before? Or maybe it is not a problem with AOL, but something wrong with my code?

Here(s the code that does the work:

Also, I(m using ZF version 1.6.0. Not sure if that is relevant.

//assuming the form is valid:
$table = new Subscribers();
$rowset = $table->fetchAll();
foreach ($rowset as $row) {
$mail = new Zend_Mail();
$mail->setBodyText($form->getElement((body()->getValue())
->setFrom((weekly-update@email.com(, (Weekly Update()
->addTo($row->email)
->setSubject($form->getElement((subject()->getValue());
$fileLocation = $form->getElement((attachment()->getValue();
$fileContents = file_get_contents($fileLocation);
$attachment = $mail->createAttachment($fileContents);
$attachment->filename = str_replace(Zend_Registry::get((config()->downloadsLocation . (/(, ((, $fileLocation);
$mail->send();
}

posted date: 2009-04-08 22:22:00


Re: Zend Framework: Some email users get errors when trying to open PDF attachments?#2
I had made out the solution of this problem. click to view my topic...

hope that hepls.

posted date: 2009-04-08 22:22:01


Re: Zend Framework: Some email users get errors when trying to open PDF attachments?#3
It appears (to me) that in this line of code:$attachment = $mail->createAttachment($fileContents);you likely need to add the additional header information available in the createAttachment method of the Zend_Mail framework::$attachment = $mail->createAttachment($fileContents, Zend_Mime::DISPOSITION_INLINE);Many larger email providers are sticklers for strict adherence to good email policy (I(ve found).Play around with this and I(m sure you(ll get it to work.

posted date: 2009-04-08 22:41:00


Re: Zend Framework: Some email users get errors when trying to open PDF attachments?#4
would that cause the file to "be corrupted"? That's what my users are telling me when they try to open it, that the file is corrupt.

posted date: 2009-04-09 02:33:00


Re: Zend Framework: Some email users get errors when trying to open PDF attachments?#5
The error usually says somethings like "Adobe could not open the file. It may be corrupted." And yeah, not having proper mime types can affect how the content is interpreted by the program. Sometimes it'll be viewed as a really long message that gets truncated (then corrupted)

posted date: 2009-04-09 10:27:00


Re: Zend Framework: Some email users get errors when trying to open PDF attachments?#6
You need those users to provide you with the message source, then you move that into a mailbox and see if you can open it. Depending on the size of the attachment, there could be an issue, etc..

posted date: 2009-04-11 05:25:00


Re: Zend Framework: Some email users get errors when trying to open PDF attachments?#7
I've read up a little more about the MIME standard, so now your answer makes a lot more sense as to why I would be having this problem. I'll post my code to show what I needed to add for specific PDF MIME stuff. Thanks for your help!

posted date: 2009-04-11 12:12:00


Re: Zend Framework: Some email users get errors when trying to open PDF attachments?#8
I also had this problem.I(d suggest you trace out the file stream info somehow. The issue with my app was that the $fileContents = file_get_contents($fileLocation); call wasn(t getting the stream of the file properly, so this is where you might be falling down.Try this:$mail = new Zend_Mail();...var_dump($mail->send());You should see a bunch of gibberish where the file stream comes out in the var_dump under the key:["_content:protected"]=> string(37129) "%PDF-1.5 etc...

posted date: 2010-02-18 21:39:00


select page: « 1 »
Copyright ©2008-2017 www.momige.com, all rights reserved.