Jump to content

SOLVED How add a Mail Template in new module


Recommended Posts

Hello.

Im developping a new module, and I need create mail templates. I did this:

pixeincidencereport/mails/en/new_incidence.html

pixeincidencereport/mails/en/new_incidence.txt

 

And the call is:

	public function sendMail($action){
		Mail::Send((int)(Configuration::get('PS_LANG_DEFAULT')), // defaut language id
        'new_incidence', // email template file to be use
        ' Module Installation', // email subject
        array(
          '{email}' => '[email protected]',//Configuration::get('PS_SHOP_EMAIL'), // sender email address
          '{message}' => ' has been installed on:'._PS_BASE_URL_.__PS_BASE_URI__ // email content
        ), 
        '[email protected]', // receiver email address 
        NULL, NULL, NULL);
	}

 

But i allways recibe the same error:

Error - dont found the email template : /home/userred/public_html/prestashopruebas/mails/es/new_incidence.txt

 

How can i do this?

THX!!

 

-----SOLVED---------

Only you have to pass the template_diretory in the function:

Mail::Send((int)(Configuration::get('PS_LANG_DEFAULT')), // defaut language id
        'new_incidence', // email template file to be use
        ' Module Installation', // email subject
        array(
          '{email}' => '[email protected]',//Configuration::get('PS_SHOP_EMAIL'), // sender email address
          '{message}' => ' has been installed on:'._PS_BASE_URL_.__PS_BASE_URI__ // email content
        ), 
        '[email protected]', // receiver email address 
        NULL, NULL, NULL,NULL,NULL,_PS_MODULE_DIR_.$this->name.'/mails/');

 

 

 

 

Edited by kurungele (see edit history)
Link to comment
Share on other sites

  • 1 year later...

I'm trying the same as you, but it's not working. 

$this->module->getLocalPath() . 'mails/'

Is also not working, and if i try to actually send a mail from a already existing template, it does work! 
Also if i try to send a test mail trough the backoffice with my new made template it does work.

PS1.7.6.1

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...