cancel
Showing results for 
Search instead for 
Did you mean: 

Zend_mail encoding for PDF

SOLVED

Zend_mail encoding for PDF

Good morning,

 

Sorry for my level in English. Could someone tell me what is blocking access to my PDF in this code?

 

$mail = new Zend_Mail('utf-8');

            $mailBody   = "Prénom : ".$first_name." <br/>
                        Nom : ".$last_name." <br/>
                        E-mail : ".$email_from." <br/>
                        
                        Sujet : Candidature à l'offre : " .$job." <br/>
                        
                        Message : ".$comments;
            $mail->setBodyHtml($mailBody)
                ->setSubject($first_name." ".$last_name ." a postulé à votre offre de ".$jobTitle)
                ->addTo($mailRecipient)
                ->setFrom($email_from, $first_name.' '.$last_name);

            $fileName = '';
            if (($_FILES["mymotivationletter"]['name']) && ($_FILES["mymotivationletter"]['name'] != '')) {
                try {

                    $uploadmotiv = $this->upload('mymotivationletter','media/recrutement',15360, array('png','gif','jpg','jpeg', 'pdf', 'doc') );
                    //file content is attached
                    $attachment = file_get_contents(Mage::getBaseUrl().$uploadmotiv);
                    $mail->createAttachment(
                        $attachment,
                        Zend_Mime::TYPE_OCTETSTREAM,
                        Zend_Mime::DISPOSITION_ATTACHMENT,
                        Zend_Mime::ENCODING_BASE64,
                        $_FILES["mymotivationletter"]['name']
                    );
                } catch (Exception $e) {
                    Mage::getSingleton('customer/session')->addError($e->getMessage());
                    $error = true;
                }


I receive the pdf files well but I can't open them, and I can't find where is the mistake.

If anyone can help me, that would be very kind.

Have a good daySmiley Happy

 

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Zend_mail encoding for PDF

Hi @julien_rouzot1 

$uploadmotiv = $this->upload('mymotivationletter','media/recrutement',15360, array('png','gif','jpg','jpeg', 'pdf', 'doc') );

 

Did you have proper permission for "media/recrutement" folder?
Please check once permission for this folder or set 777 permission using following command.

 

sudo chmod -R 0777 media/recrutement

Also check manually once that your PDF file is generated in the media/recrutement folder. Download it and try to open.

I hope it will help you!

 

View solution in original post

2 REPLIES 2

Re: Zend_mail encoding for PDF

Hi @julien_rouzot1 

$uploadmotiv = $this->upload('mymotivationletter','media/recrutement',15360, array('png','gif','jpg','jpeg', 'pdf', 'doc') );

 

Did you have proper permission for "media/recrutement" folder?
Please check once permission for this folder or set 777 permission using following command.

 

sudo chmod -R 0777 media/recrutement

Also check manually once that your PDF file is generated in the media/recrutement folder. Download it and try to open.

I hope it will help you!

 

Re: Zend_mail encoding for PDF

Thank you Vimal Smiley Happy