Jump to content

[PS 1.7] add attachments to custom email template


Recommended Posts

I have my own email template and my own email feature.
I need to add several pdf files and one xml file to these emails.

I use:

$attach = array();
$fname = Tools::getValue('fname');
$content = file_get_contents(_PS_MODULE_DIR_.$this->name.'/data/'.$fname);
$attach['content'] = $content;
$attach['name'] = $fname;
$attach['mime'] = 'application/xml';

I still need to add a few PDF files, where I can read their list from the database.


SELECT id_pdf from my_table where id = 2;
// result = 1,3,6,8,12,25

PDF file names are explode numbers.

1.pdf, 3.pdf, 6.pdf, 8.pdf, 12.pdf, 25.pdf

I need to add these pdfs to an email.

Cannot use hookActionEmailSendBefore method !!!

              Configuration::get('PS_LANG_DEFAULT'), // defaut language id
              'my_template', // email template file to be use
              $subject, // email subject
                  '{params1}' => $params1, 
                  '{params2}' => $params2
              Tools::getValue('email'), // receiver email address
              null, // receiver name
              Configuration::get('PS_SHOP_EMAIL'), // sender email
              Configuration::get('PS_SHOP_NAME'), // sender name
              $attach, // attachment XML + PDFs
              null, // smtp
              null, // mails dir
              false, // errors
              null, // id shop
              null, // bcc
              null); // reply to;


Thank you.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...