kobjectt Posted August 19, 2016 Share Posted August 19, 2016 Hi all, When someone orders something, they will receive a mail with a PDF as a conformation with their order! How can i make this e-mail with a BCC so it will send it to my admin email with ALL the orders? Link to comment Share on other sites More sharing options...
bellini13 Posted August 19, 2016 Share Posted August 19, 2016 you can install the mail alerts module so that you can receive an email with each new order Link to comment Share on other sites More sharing options...
vekia Posted August 19, 2016 Share Posted August 19, 2016 if you want to receive exactly the same emails as customer receives (and all the messages that your shop sends) you can add setBcc() function to mail::send class open classes/Mail.php - you can find there public static function Send() before $send = $swift->send($message); add: $message->setBcc(array('[email protected]')) so prestashop will send blind carbon copy emails to [email protected] 1 Link to comment Share on other sites More sharing options...
kobjectt Posted August 19, 2016 Author Share Posted August 19, 2016 if you want to receive exactly the same emails as customer receives (and all the messages that your shop sends) you can add setBcc() function to mail::send class open classes/Mail.php - you can find there public static function Send() before $send = $swift->send($message); add: $message->setBcc(array('[email protected]')) so prestashop will send blind carbon copy emails to [email protected] Thanks for the fast reply, This seems something i need. But i only want the mails with PDF included to have a BCC. The other mails not! Link to comment Share on other sites More sharing options...
vekia Posted August 19, 2016 Share Posted August 19, 2016 you can create if condition that will check if mail has a file attachments: $file_attachment if ($file_attachment && !empty($file_attachment)) { $message->setBcc(array('[email protected]')) } 1 Link to comment Share on other sites More sharing options...
kobjectt Posted August 19, 2016 Author Share Posted August 19, 2016 you can create if condition that will check if mail has a file attachments: $file_attachment if ($file_attachment && !empty($file_attachment)) { $message->setBcc(array('[email protected]')) } I got something like this now: /* Send mail */ $message->setFrom(array($from => $from_name)); $message->setBcc(array('mail@mail')) $send = $swift->send($message); ShopUrl::resetMainDomainCache(); if ($send && Configuration::get('PS_LOG_EMAILS')) { $mail = new Mail(); $mail->template = Tools::substr($template, 0, 62); $mail->subject = Tools::substr($subject, 0, 254); $mail->id_lang = (int)$id_lang; $recipients_to = $message->getTo(); $recipients_cc = $message->getCc(); $recipients_bcc = $message->getBcc(); if (!is_array($recipients_to)) { $recipients_to = array(); } if (!is_array($recipients_cc)) { $recipients_cc = array(); } if (!is_array($recipients_bcc)) { $recipients_bcc = array(); } if ($file_attachment && !empty($file_attachment)) { $message->setBcc(array('[email protected]')) } This is how it should be? Link to comment Share on other sites More sharing options...
vekia Posted August 19, 2016 Share Posted August 19, 2016 hello,yes, it will check if email has attachment, and if so - shop will send bcc Link to comment Share on other sites More sharing options...
kobjectt Posted August 19, 2016 Author Share Posted August 19, 2016 (edited) It seems it working now, But only the BCC when only a file is attached seems not to work, any issues here? if ($file_attachment && !empty($file_attachment)) { $message->setBcc(array('[email protected]')); } Edited August 19, 2016 by kobjectt (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted August 19, 2016 Share Posted August 19, 2016 you mean that you receive bcc no matter if mail has attachment or not? Link to comment Share on other sites More sharing options...
kobjectt Posted August 19, 2016 Author Share Posted August 19, 2016 you mean that you receive bcc no matter if mail has attachment or not? Yes, the mail for only mails with attachments wont recieve any mails. I also see it in Sendgrid. Because Sendgrid dont show any mails to the address. Link to comment Share on other sites More sharing options...
vekia Posted August 20, 2016 Share Posted August 20, 2016 im not sure whats up,i asked about you mean that you receive bcc no matter if mail has attachment or not? then you confirmed Yes, but you also said that no email is delivered to your mailbox the mail for only mails with attachments wont recieve any mails so let's clarify what's up now because im a little confused thank you! Link to comment Share on other sites More sharing options...
kobjectt Posted August 21, 2016 Author Share Posted August 21, 2016 im not sure whats up, i asked about then you confirmed but you also said that no email is delivered to your mailbox so let's clarify what's up now because im a little confused thank you! First off all nothing seems to work, but after some little tweaking the BBC function seems to work fine. But this function works only for all the mails that has been sended through out the Prestashop mail. The configuration to add BBC only to mails with a attachment is not working at the moment, this is what i have now! $message->setFrom(array($from => $from_name)); $message->setBcc(array('[email protected]')); $send = $swift->send($message); ShopUrl::resetMainDomainCache(); if ($file_attachment && !empty($file_attachment)) { $message->setBcc(array('[email protected]')); } if ($send && Configuration::get('PS_LOG_EMAILS')) { $mail = new Mail(); $mail->template = Tools::substr($template, 0, 62); $mail->subject = Tools::substr($subject, 0, 254); $mail->id_lang = (int)$id_lang; $recipients_to = $message->getTo(); $recipients_cc = $message->getCc(); $recipients_bcc = $message->getBcc(); if (!is_array($recipients_to)) { $recipients_to = array(); } if (!is_array($recipients_cc)) { $recipients_cc = array(); } if (!is_array($recipients_bcc)) { $recipients_bcc = array(); } So the following part is not working ATM: if ($file_attachment && !empty($file_attachment)) { $message->setBcc(array('[email protected]')); } Link to comment Share on other sites More sharing options...
dusticelli Posted September 5, 2016 Share Posted September 5, 2016 if you want to receive exactly the same emails as customer receives (and all the messages that your shop sends) you can add setBcc() function to mail::send class open classes/Mail.php - you can find there public static function Send() before $send = $swift->send($message); add: $message->setBcc(array('[email protected]')) so prestashop will send blind carbon copy emails to [email protected] Thx! After the last update to 1.6.1.6 my former customisation (it was on tools/swift.php) did no longer effect. This works like a charme! Link to comment Share on other sites More sharing options...
matracon Posted October 28, 2016 Share Posted October 28, 2016 Hi Vekia: if you want to receive exactly the same emails as customer receives (and all the messages that your shop sends) you can add setBcc() function to mail::send class open classes/Mail.php - you can find there public static function Send() before $send = $swift->send($message); add: $message->setBcc(array('[email protected]')) so prestashop will send blind carbon copy emails to [email protected] I did this, but it does not work , please help!!! , PS 1.6.1.6 Thanks Link to comment Share on other sites More sharing options...
pierrepli Posted October 18, 2018 Share Posted October 18, 2018 (edited) Hi, To follow this discussion, I'd like to send BBC to the group leader of the customer ('email_boss' field added in table ps_group). How would I send a BCC to email_boss ? Thanks Edited October 18, 2018 by pierrepli (see edit history) Link to comment Share on other sites More sharing options...
rb10 Posted April 17, 2019 Share Posted April 17, 2019 hi, i have tried this and i receive bcc but not attached.... Link to comment Share on other sites More sharing options...
rb10 Posted April 17, 2019 Share Posted April 17, 2019 On 19/8/2016 at 14:29, vekia said: se vuoi ricevere esattamente le stesse email ricevute dal cliente (e tutti i messaggi che il tuo negozio invia) puoi aggiungere la funzione setBcc () alla classe mail :: send open classes / Mail.php - puoi trovare lì la funzione statica pubblica Send () prima Inserisci: quindi prestashop invierà e-mail in copia carbone a [email protected] hi, i have try your adivce, and mail bcc sent ok, but there isnt any attached file.... Link to comment Share on other sites More sharing options...
SteevenQuijije Posted February 10, 2020 Share Posted February 10, 2020 On 8/19/2016 at 2:29 PM, vekia said: if you want to receive exactly the same emails as customer receives (and all the messages that your shop sends) you can add setBcc() function to mail::send class open classes/Mail.php - you can find there public static function Send() before $send = $swift->send($message); add: $message->setBcc(array('[email protected]')) so prestashop will send blind carbon copy emails to [email protected] With Prestashop 1.7.5 didn't work 😐 Link to comment Share on other sites More sharing options...
M.N Posted November 18, 2020 Share Posted November 18, 2020 It work with PS 1.7.6.8. Just make sure your sentence ends with ; Transfer to: /override/classes/Mail.php , line 589 $message->setBcc(array('[email protected]')); so the two lines will look like: $message->setBcc(array('[email protected]')); $send = $swift->send($message); Link to comment Share on other sites More sharing options...
comunicazione Posted January 22, 2021 Share Posted January 22, 2021 any idea to filter Bcc copy just for mails with a specific subject? Tnx Link to comment Share on other sites More sharing options...
hhennes Posted January 28, 2021 Share Posted January 28, 2021 A proper method for the prestashop 1.7 version is to use the hook actionEmailSendBefore in a module. In this hook you have access to all the emails vars : cf. https://github.com/PrestaShop/PrestaShop/blob/develop/classes/Mail.php#L154 Then in your module you can add a condition on the template send with something like this /** * Executed before an email is end * @param array $params * @return void */ public function hookActionEmailSendBefore($params) { if ( $params['template'] == 'template_code' ) { $params['bcc'] = ['[email protected]']; } } Link to comment Share on other sites More sharing options...
comunicazione Posted February 1, 2021 Share Posted February 1, 2021 On 8/19/2016 at 4:25 PM, vekia said: Thank you hhennes for your suggestion, but actually to follow it I need some insights on php and in prestashop modues making ( i'm studying..;-). I Thought a more simple action similar to the method suggested by vekia working on Mail.php ... you can create if condition that will check if mail has a file attachments: $file_attachment if ($file_attachment && !empty($file_attachment)) { $message->setBcc(array('[email protected]')) } Link to comment Share on other sites More sharing options...
hhennes Posted February 1, 2021 Share Posted February 1, 2021 Hello, If you are studying, the best advise i can give you is to try to do it the right way directly Avoid to use override when they are not necessary. If you still need to do it directly on Mail class, simply add a condition on the template name if ( $template == 'your_template){ //Add bcc here } Regards 1 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