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('[email protected]', '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();
}