arslantabassum Posted May 30, 2014 Share Posted May 30, 2014 (edited) I have code to send email in my module... and email working.. i have file and also file path. But don't know how to attach file with it.????Here is code: $currency = $this->context->currency; $customer = new Customer((int)$order->id_customer); $params['{lastname}'] = $customer->lastname; $params['{firstname}'] = $customer->firstname; $params['{order_name}'] = $res_main["reference"]; $params['{pm_reference}'] = $xml->pm_reference; $params['{way_bill}'] = $xml->label_url; $params['{voucher_num}'] = $message; $customer = new Customer((int)$order->id_customer); @Mail::Send((int)$order->id_lang, 'payment_pm', sprintf(Mail::l('Way Bill is Attached%s', (int)$order->id_lang), $order->reference), $params, $customer->email, $customer->firstname.' '.$customer->lastname, null, null, null, $null, _PS_MAIL_DIR_, true, (int)$order->id_shop);the file path is:_PS_ROOT_DIR_.'/administration/'.$order->id.'_'.$product['id_product'].'.pdf'Please Attach this file in the email.. All suggestions are appreciated>.....thanks in advance..... Edited June 2, 2014 by arslantabassum (see edit history) Link to comment Share on other sites More sharing options...
NemoPS Posted May 30, 2014 Share Posted May 30, 2014 Attachment comes right after "from_name" public static function Send($id_lang, $template, $subject, $template_vars, $to, $to_name = null, $from = null, $from_name = null, $file_attachment = null, $mode_smtp = null, $template_path = _PS_MAIL_DIR_, $die = false, $id_shop = null, $bcc = null) You have to upload the file to the server first, then pass its path instead of null to that parameter 1 Link to comment Share on other sites More sharing options...
arslantabassum Posted June 2, 2014 Author Share Posted June 2, 2014 Attachment comes right after "from_name" public static function Send($id_lang, $template, $subject, $template_vars, $to, $to_name = null, $from = null, $from_name = null, $file_attachment = null, $mode_smtp = null, $template_path = _PS_MAIL_DIR_, $die = false, $id_shop = null, $bcc = null) You have to upload the file to the server first, then pass its path instead of null to that parameter Thanks It works Great..... Now the Modified Working Example ...... $fileAttachment['content'] = file_get_contents(_PS_ROOT_DIR_.'/administration/file.pdf'); //File path $fileAttachment['name'] = 'WayBill'; //Attachment filename $fileAttachment['mime'] = 'application/pdf'; //mime file type $currency = $this->context->currency; $customer = new Customer((int)$order->id_customer); $params['{lastname}'] = $customer->lastname; $params['{firstname}'] = $customer->firstname; $params['{order_name}'] = $res_main["reference"]; $params['{pm_reference}'] = $xml->pm_reference; $params['{way_bill}'] = $xml->label_url; $params['{voucher_num}'] = $message; $customer = new Customer((int)$order->id_customer); @Mail::Send((int)$order->id_lang, 'payment_pm', sprintf(Mail::l('Way Bill is Attached%s', (int)$order->id_lang), $order->reference), $params, $customer->email, $customer->firstname.' '.$customer->lastname, null, null, $fileAttachment, null, _PS_MAIL_DIR_, true, (int)$order->id_shop); Thanks Once Again....... 2 Link to comment Share on other sites More sharing options...
Recommended Posts