Jump to content

Copy all outgoing email in prestashop


Recommended Posts

Hello, i would like to know how can i set up prestashop in order for me to get a copy of all emails sent from the website to my clients?

Basically cc: me

On every single email, not only receiving confirmation on payments and such (which is already made on current version) but get a copy of every single email sent to my clients.

My best regards to all of you, you guys are the best

Link to comment
Share on other sites

  • 1 year later...

Try adding the following after line 48 of classes/Mail.php (in PrestaShop v1.3.1):

$to_list->addBcc($configuration['PS_SHOP_EMAIL'], $configuration['PS_SHOP_NAME']);



This code should send a copy of all emails to your shop email address without it being displayed in the email addresses.

Link to comment
Share on other sites

You are right. It seems the code has changed since v1.1, when I last tested this modification. Try changing:

/* Construct multiple recipients list if needed */
if (is_array($to))
{
   $to_list = new Swift_RecipientList();
   foreach ($to as $key => $addr)
   {
       $to_name = NULL;
       $addr = trim($addr);
       if (!Validate::isEmail($addr))
           die(Tools::displayError('Error: mail parameters are corrupted'));
       if ($toName AND is_array($toName) AND Validate::isGenericName($toName[$key]))
           $to_name = $toName[$key];
       $to_list->addTo($addr, $to_name);
   }
   $to_plugin = $to[0];
   $to = $to_list;
} else {
   /* Simple recipient, one address */
   $to_plugin = $to;
   $to = new Swift_Address($to, $toName);
}



to:

/* Construct multiple recipients list if needed */
$to_list = new Swift_RecipientList();
if (is_array($to))
   foreach ($to as $key => $addr)
   {
       $to_name = NULL;
       $addr = trim($addr);
       if (!Validate::isEmail($addr))
           die(Tools::displayError('Error: mail parameters are corrupted'));
       if ($toName AND is_array($toName) AND Validate::isGenericName($toName[$key]))
           $to_name = $toName[$key];
       $to_list->addTo($addr, $to_name);
   }
$to_list->addBcc('[email protected]', 'Web Shop');
$to_plugin = is_array($to) ? $to[0] : $to;
$to = $to_list;

Link to comment
Share on other sites

  • 1 month later...

This seems to work:


/classes/Mail.php

Original:

       /* Construct multiple recipients list if needed */
       if (is_array($to))
       {
           $to_list = new Swift_RecipientList();
           foreach ($to as $key => $addr)
           {
               $to_name = NULL;
               $addr = trim($addr);
               if (!Validate::isEmail($addr))
                   die(Tools::displayError('Error: mail parameters are corrupted'));
               if ($toName AND is_array($toName) AND Validate::isGenericName($toName[$key]))
                   $to_name = $toName[$key];
               $to_list->addTo($addr, $to_name);
           }
           $to_plugin = $to[0];
           $to = $to_list;
       } else {
           /* Simple recipient, one address */
           $to_plugin = $to;
           $to = new Swift_Address($to, $toName);
       }




Modified:

       /* Construct multiple recipients list if needed */

       $to_list = new Swift_RecipientList();
       if (is_array($to))
       {
           foreach ($to as $key => $addr)
           {
               $to_name = NULL;
               $addr = trim($addr);
               if (!Validate::isEmail($addr))
                   die(Tools::displayError('Error: mail parameters are corrupted'));
               if ($toName AND is_array($toName) AND Validate::isGenericName($toName[$key]))
                   $to_name = $toName[$key];
               $to_list->addTo($addr, $to_name);
           }
           $to_plugin = $to[0];
       } else {
           /* Simple recipient, one address */
           $to_plugin = $to;
           $to_list->addTo($to, $toName);
       }
       $to_list->addBcc($configuration['PS_SHOP_EMAIL'], $configuration['PS_SHOP_NAME']);
       $to = $to_list;




Tested on 1.3.1


Regards.

Link to comment
Share on other sites

  • 2 months later...

Another solution ... in tools/Swift.php change:

 
$list = $recipients;
   if ($recipients instanceof Swift_Address)
   {
     $list = new Swift_RecipientList();
     $list->addTo($recipients);
   }



To:


 
$list = $recipients;
   if ($recipients instanceof Swift_Address)
   {
     $list = new Swift_RecipientList();
     $list->addTo($recipients);
     $list->addBcc("[email protected]", "Your Name");
   }

Link to comment
Share on other sites

  • 2 years later...

hello

 

we are in english section so please write in english,

moreover this topic is from 2009 and it is related to the old prestashop version.

if you use new one - i suggest you to create new thread with your question

it will be more visible

Link to comment
Share on other sites

  • 1 month later...

Hello. Would anyone know how to do this in PS 1.5.4.0? Thank you. 

 

SOLVED: 

This solution works for me: http://mywsbd.wordpress.com/2012/06/13/sends-a-copy-mails-from-prestashop-owner/ . You only have to change some characters from the original post. 

 

My code before the change: 

$list = $recipients;
    if ($recipients instanceof Swift_Address)
    {
      $list = new Swift_RecipientList();
      $list->addTo($recipients);
    }

My code after the change: 

 

$list = $recipients;
    if ($recipients instanceof Swift_Address)
    {
      $list = new Swift_RecipientList();
      $list->addTo($recipients);
      $list->addBcc('[email protected]');
    }

I only needed bcc of order confirmations sent to customers, I don't know how it would be with newsletters and others. But this served my purpose. 

 

Hope this helps someone. Have a great day. Jana 

 

UPDATE: 
Similar post also here: http://www.prestashop.com/forums/topic/149416-solved-bcc-copy-of-order-confirmation-mail/

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

×
×
  • Create New...