Adding Zend_Mail Attachments from a Zend_Form

If you ever need to get your Zend_Form_Element_File to be attached to your Zend_Mail, here’s how it’s done!

$mail = new Zend_Mail();
$at = new Zend_Mime_Part(file_get_contents($form->upload->getFileName()));
            $at->type           = $form->upload->getMimeType();
            $at->disposition = Zend_Mime::DISPOSITION_ATTACHMENT;
            $at->encoding    = Zend_Mime::ENCODING_BASE64;
            $at->filename    = basename($form->upload->getFileName());
            $mail->addAttachment($at);
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s