Jump to content
mickeymouse

Hardcoding Mail at mailalert module

Recommended Posts

hi,

 

anyone can tell me in which php or tpl file i should hardcode an extra notification mail?

 

i must relay trust on a second admin for some time and i would like to hardcode

an extra mail to keep track of new orders,

 

I know MailAlerts module inserts into mysql BD the mails you put in the config option

of the module,

but i would like to "add" another mail hardcoded in the php code,

 

i looked into all files inside modules\mailalerts\

but i dont even find the mail() function of php, so i have no idea about what function prestashop

is using to send mails..

 

any info about that and how to solve the problem will be grateful,

 

thanks

Share this post


Link to post
Share on other sites

Assuming this is PS v1.5, inside mailalerts.php is a function hookActionValidateOrder. At the end of the function is where the mail is sent. $this->_merchant_mails contains the recipient email addresses, so you will need to merge your email address with this.

 

   	 if (file_exists(dirname(__FILE__).'/mails/'.$iso.'/'.$template.'.txt') &&
           file_exists(dirname(__FILE__).'/mails/'.$iso.'/'.$template.'.html'))
           Mail::Send(
               $id_lang,
               $template,
               sprintf(Mail::l('New order - #%06d', $id_lang), $order->id),
               $template_vars,
               explode(self::__MA_MAIL_DELIMITOR__, $this->_merchant_mails),
               null,
               $configuration['PS_SHOP_EMAIL'],
               $configuration['PS_SHOP_NAME'],
               null,
               null,
               dirname(__FILE__).'/mails/'
           );

Share this post


Link to post
Share on other sites

Thank you so much for pointing me to the specific code block where the mail function in executed,

i was always searching for " mail( " string in order to find the start of the function but i was looking in a wrong way,

 

i never used that kind of way to send mails so i still don't success in the implementation,

 

i tried to see if concatenating a string of the mail may do the trick, but it didn't

 

explode(self::__MA_MAIL_DELIMITOR__, $this->_merchant_mails).'extramail@gmail.com',

 

 

as far as i know explode is saving into an array the mail list inside _merchant_mails

but i still don't success making it add a new value to this array,

should i use array_push() function ?

Share this post


Link to post
Share on other sites

here is how I would accomplish. This is not tested, but might actually work :)

 

$recipients are the existing merchant mails

$my_recipient is your hard coded email

 

they are then merged together into $recipients, $recipients is then passed to the Mail::Send function

 

$recipients=explode(self::__MA_MAIL_DELIMITOR__, $this->_merchant_mails);
$my_recipient = array('john smith' => 'johnsmith@gmail.com');
$recipients = array_merge((array)$recipients, (array)$my_recipient);

if (file_exists(dirname(__FILE__).'/mails/'.$iso.'/'.$template.'.txt') &&
file_exists(dirname(__FILE__).'/mails/'.$iso.'/'.$template.'.html'))
Mail::Send(
$id_lang,
$template,
sprintf(Mail::l('New order - #%06d', $id_lang), $order->id),
$template_vars,
$recipients,
null,
$configuration['PS_SHOP_EMAIL'],
$configuration['PS_SHOP_NAME'],
null,
null,
dirname(__FILE__).'/mails/'
);

Share this post


Link to post
Share on other sites

hi,

 

the code must work well, however it does not, looks like the module is not working properly

 

when i test the mailing module with 1 mail it works well, so i supposed it must work well with more mails as it states "one mail per line" in the config option of the module.

 

so i tested the code, that looks perfectly well done in with my local web server and a local mail server.

 

smtp server log return this error ---> 00:53:00 [16] Error: Too many recipients

 

however it still send the mail to the user, but not to any of the mails setup,

 

then i tested to reset to the original code, and then put two mails in the module, and test it,

 

result? not working... exactly same error when there is more than one mail

 

its strange to see it working with just one mail but none of them if used two,

 

overall, the code looks like works good, and the problem must be in the way mail module works when there is more than 1 mail,

Edited by mickeymouse (see edit history)

Share this post


Link to post
Share on other sites

i end up making it work successfully by just cloning the block Mail::Send(...);

and replacing the explode() code by just a string with the mail in the second block,

 

this way all mails are sent,

 

 

some one should revise the mailalert module as if there are more than two mail receptors, none of them receive a notification mail...

at least in my local test's

Edited by mickeymouse (see edit history)

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More