bahamont Posted May 15, 2014 Share Posted May 15, 2014 (edited) I want to send an automatic email when a module is installed. The mail is sent by the module using the email system to the shop.Anyone can help me? Edited May 15, 2014 by bahamont (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted May 15, 2014 Share Posted May 15, 2014 in module install() function you can use php native function to send emails:Maill::Send(); Link to comment Share on other sites More sharing options...
bahamont Posted May 16, 2014 Author Share Posted May 16, 2014 i tried that, but i don't receive any email: mail("[email protected]", $text,$text) Link to comment Share on other sites More sharing options...
bellini13 Posted May 16, 2014 Share Posted May 16, 2014 mail("[email protected]", $text,$text) is not the same as Maill::Send() Open the mailalerts module and review how the module sends an email, and you should be able to figure it out 1 Link to comment Share on other sites More sharing options...
vekia Posted May 16, 2014 Share Posted May 16, 2014 i tried that, but i don't receive any email: mail("[email protected]", $text,$text) take a look on function definition: /** * Send Email * * @param int $id_lang Language of the email (to translate the template) * @param string $template Template: the name of template not be a var but a string ! * @param string $subject * @param string $template_vars * @param string $to * @param string $to_name * @param string $from * @param string $from_name * @param array $file_attachment Array with three parameters (content, mime and name). You can use an array of array to attach multiple files * @param bool $modeSMTP * @param string $template_path * @param bool $die * @param string $bcc Bcc recipient */ 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) Link to comment Share on other sites More sharing options...
Rolige Posted May 16, 2014 Share Posted May 16, 2014 i tried that, but i don't receive any email: mail("[email protected]", $text,$text) The default php function is: mail('[email protected]', 'Subject here', 'Message here...'); And as vekia said, just insert on the install() function in: classes/module/Module.php Also can use the default Mail class of prestashop. Link to comment Share on other sites More sharing options...
gonebdg - webindoshop.com Posted May 18, 2014 Share Posted May 18, 2014 (edited) First, make sure your Prestashop was able to send email, and then try this : public function install() { Mail::Send((int)(Configuration::get('PS_LANG_DEFAULT')), // defaut language id 'contact', // email template file to be use $this->displayName.' Module Installation', // email subject array( '{email}' => Configuration::get('PS_SHOP_EMAIL'), // sender email address '{message}' => $this->displayName.' has been installed on:'._PS_BASE_URL_.__PS_BASE_URI__ // email content ), '[email protected]', // receiver email address NULL, NULL, NULL); // Your module installation process here } Edited May 18, 2014 by gonebdg - webindoshop.com (see edit history) 1 Link to comment Share on other sites More sharing options...
bahamont Posted May 29, 2014 Author Share Posted May 29, 2014 (edited) First, make sure your Prestashop was able to send email, and then try this : public function install() { Mail::Send((int)(Configuration::get('PS_LANG_DEFAULT')), // defaut language id 'contact', // email template file to be use $this->displayName.' Module Installation', // email subject array( '{email}' => Configuration::get('PS_SHOP_EMAIL'), // sender email address '{message}' => $this->displayName.' has been installed on:'._PS_BASE_URL_.__PS_BASE_URI__ // email content ), '[email protected]', // receiver email address NULL, NULL, NULL); // Your module installation process here } The template my email is in a folder within the module itself. Is there any way to tell the path of template? I have installed prestashop in a local server and got this error message when installing the module: [2] mail (): Failed to connect to mailserver at "localhost" port 25, Verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set () Is it because I have a local server? Edited May 29, 2014 by bahamont (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted May 29, 2014 Share Posted May 29, 2014 The template my email is in a folder within the module itself. Is there any way to tell the path of template? I have installed prestashop in a local server and got this error message when installing the module: [2] mail (): Failed to connect to mailserver at "localhost" port 25, Verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set () Is it because I have a local server? yes, it's because you're on localhost if you haven't got on your localhost any smtp service - it will not work. you can try to use SMTP connection to some remote service like gmail you can set it up under adv. parameters > mail tab in back office. Link to comment Share on other sites More sharing options...
gonebdg - webindoshop.com Posted May 29, 2014 Share Posted May 29, 2014 The template my email is in a folder within the module itself. Is there any way to tell the path of template? Take a look on Vekia post above, @param string $template_path http://www.prestashop.com/forums/topic/330853-send-a-email-with-prestashop-code/?do=findComment&comment=1674051 You will need to add/define the parameter $template_path if you wanna use custom email template file which placed in your module directory Is it because I have a local server? if you're use Xampp, don't forget to activate and configure Mercury module also don't forget to install Free and Open Source Webmail Software, like Rouncube on your localhost. Otherwise you won't be able to send/receive/read email within your localhost system.I hope you're understand how to use Xampp-Mercury module Link to comment Share on other sites More sharing options...
bahamont Posted June 1, 2014 Author Share Posted June 1, 2014 (edited) I create the $template_patch variable,but prestashop don't search in that url This is the code: $template_path = dirname(__FILE__).'/mails/'; Mail::Send((int)(Configuration::get('PS_LANG_DEFAULT')), // defaut language id 'template', // email template file to be use $this->displayName.' Module Installation', // email subject array( '{email}' => Configuration::get('PS_SHOP_EMAIL'), // sender email address '{message}' => $this->displayName.' has been installed on:'._PS_BASE_URL_.__PS_BASE_URI__ // email content ), '[email protected]', // receiver email address NULL, NULL, NULL, $template_path); Prestashop search in: C:\Users\name_user\www\prestashop/mails/es/template.txt The file is in: C:\Users\name_user\www\prestashop/modules/name_module/mails/es/template.txt What is wrong? Edited June 1, 2014 by bahamont (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