Dev D4v3 Posted January 8, 2019 Share Posted January 8, 2019 Hello. I want to send an email with an attachment but i have a weird issue. My mail is sent with the message but not the attachment. I'm stuck, please help me. Here is my code include('../config/config.inc.php'); require_once(dirname(__FILE__).'/../init.php'); $file_attachment=array(); $content = file_get_contents(_PS_ROOT_DIR_.'/_leptis/PDF_20121109_2.pdf'); $file_attachment['content'] = $content; $file_attachment['name'] ='RandomPDF'; $file_attachment['mime'] = 'application/pdf'; Mail::Send((int)(Configuration::get('PS_LANG_DEFAULT')), // defaut language id 'contact', // email template file to be use 'Export auto commandes du xxxxxxx', // email subject array( '{email}' => Configuration::get('PS_SHOP_EMAIL'), // sender email address '{message}' => 'This is a test message.', // email content ), '[email protected]', // receiver email address null, //Receiver name Configuration::get('PS_SHOP_EMAIL'), //Sender email Configuration::get("PS_SHOP_NAME"), // Sender name $file_attachment, //Attachment null, //SMTP mode _PS_MAIL_DIR_, //Mails directory true //Die after error? ); Link to comment Share on other sites More sharing options...
renaud2263 Posted August 14, 2019 Share Posted August 14, 2019 Bonjour, j'ai exactement le même problème sur ma 1.6. Vous avez trouvé une soluce ? Link to comment Share on other sites More sharing options...
MEG Venture Posted August 18, 2019 Share Posted August 18, 2019 The function is like below: 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 like $file_attachment['content'] = file_get_contents(_PS_ROOT_DIR_.'/_leptis/PDF_20121109_2.pdf'); //File path Try not to use the $content variable. Link to comment Share on other sites More sharing options...
hakeryk2 Posted September 2, 2019 Share Posted September 2, 2019 Well, I have the same question. Just wtf is $file_attachment['content']? What is this suppose to be? An uri to a file? Direct file? File opened with fread? What is this? Link to comment Share on other sites More sharing options...
MEG Venture Posted September 6, 2019 Share Posted September 6, 2019 It is a file uri. Link to comment Share on other sites More sharing options...
hakeryk2 Posted September 7, 2019 Share Posted September 7, 2019 (edited) No it isn't. I checked and it's need to be a file grabbed with file_get_contents from uri or by curl. Passing only url or uri is not giving nothing. You answered this properly before. Edited September 7, 2019 by hakeryk2 (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now