Jump to content

Order confirmation BCC


grumpyomg

Recommended Posts

Is there a way to send a blind copy of order confirmation emails?

 

After reading https://www.prestashop.com/forums/topic/550476-order-mails-bcc/ I've set up classes/Mail.php to send blind copies of all emails but Ideally I really only want to send copies of order confirmation emails.

 

In it's current setup I get blind copies of registration , payment accepted emails as well etc.

 

I'm using prestashop 1.6.1.9

 

Any help would be appreciated.

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

Thanks for the reply.

 

I'm trying to send a BCC email to trustpilot AFS 2.0 on order confirmation.

 

I've tried using mail alerts previously but I don't think they are sent BCC rather a new email is generated and sent to the added email addresses.

 

Any other suggestions on implementing trustpilot AFS?

Link to comment
Share on other sites

PS v1.6.1.9 supports the BCC option when sending mails. 

 

So you could still use mailalerts to send the merchant the new order email, and then you could override or customization the mailalerts module so that it adds the email address as BCC when sending the new order alert email.

 

I don't know what version of MailAlerts module you are using, but here is an example of the code you could use

 

directly after $id_shop variable is where you would add the email address for BCC.  Make sure to add a comma after $id_shop

            if ($dir_mail)
                Mail::Send(
                    $mail_id_lang,
                    'new_order',
                    sprintf(Mail::l('New order : #%d - %s', $mail_id_lang), $order->id, $order->reference),
                    $template_vars,
                    $merchant_mail,
                    null,
                    $configuration['PS_SHOP_EMAIL'],
                    $configuration['PS_SHOP_NAME'],
                    null,
                    null,
                    $dir_mail,
                    null,
                    $id_shop,
                    '[email protected]',
                );
Link to comment
Share on other sites

I'm using mail alerts v3.6.1.

 

I tried updating mailalerts.php with the above changes but it failed to work.

 

To allow trustpilot afs to work I need the customer email to be in the 'to' field and trustpilot email in the BCC. By adding the above BCC I think trustpilots automatic feedback email will be sent to the admin email rather than the customer.

 

I thought it would be straightforward to use trustpilot afs but has proven more difficult than I thought.

 

Thanks for the help. Any other ideas?

Link to comment
Share on other sites

if the customers email has to be in the To field, then you can't use mailalerts module for this.  It does not send the email to the customer.

 

The alternative is to override or customize the PaymentModule class.  It is responsible for sending the order confirmation email to the customer.  It would be a similar change as noted above.

Link to comment
Share on other sites

  • 4 weeks later...

Got the trustpilot AFS to work in version 1.6.1.9 using the help above.

 

In the PaymentModule.php class find this code.

                        if (Validate::isEmail($this->context->customer->email)) {
                            Mail::Send(
                                (int)$order->id_lang,
                                'order_conf',
                                Mail::l('Order confirmation', (int)$order->id_lang),
                                $data,
                                $this->context->customer->email,
                                $this->context->customer->firstname.' '.$this->context->customer->lastname,
                                null,
                                null,
                                $file_attachement,
                                null, _PS_MAIL_DIR_, false, (int)$order->id_shop
                            );

and replace with

                        if (Validate::isEmail($this->context->customer->email)) {
                            Mail::Send(
                                (int)$order->id_lang,
                                'order_conf',
                                Mail::l('Order confirmation', (int)$order->id_lang),
                                $data,
                                $this->context->customer->email,
                                $this->context->customer->firstname.' '.$this->context->customer->lastname,
                                null,
                                null,
                                $file_attachement,
                                null, _PS_MAIL_DIR_, false, (int)$order->id_shop,
				'*********@invite.trustpilot.com'
                            );

Replacing the ********* with your trustpilot AFS address.

 

  • Like 1
Link to comment
Share on other sites

i prefer to override the mail.php class to send a mail copy to trustpilot only when "shipped" template is sent, but don't know if is correct this way:

<?php

class Mail extends MailCore
{
    
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, $reply_to = null)
{
    // send to Trustpilot SFA 2.0
    if($template == 'shipped')
    {
        // send to trustpilot
        parent::Send($id_lang, $template, $subject, $template_vars, "*********@invite.trustpilot.com", $to_name, $from, $from_name, $file_attachment, $mode_smtp, $template_path, $die, $id_shop, $bcc, $reply_to);
    }
     
}

?>
Edited by ANGELO Vintage (see edit history)
Link to comment
Share on other sites

Has this been tested?

 

billini13's solution in #4 works for me on Presta 1.6.1.14, but I'm unsure when in the order flow the email is sent to Trustpilot? I believe the email is sent when the payment is fulfilled, which is the same time as the products are sent in my case.

Link to comment
Share on other sites

or is possible to add a bcc destination only like:

<?php
class Mail extends MailCore
{
    
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, $reply_to = null)
{
    // add trustpilot SFA 2.0
    if($template == 'shipped')
    {
        $bcc->addBcc('*********@invite.trustpilot.com');
    }      
    
    // send to customer
    $ret = parent::Send($id_lang, $template, $subject, $template_vars, $to, $to_name, $from, $from_name, $file_attachment, $mode_smtp, $template_path, $die, $id_shop, $bcc, $reply_to);
    return $ret;
}
?>

Thanks for any help

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

Has this been tested?

 

billini13's solution in #4 works for me on Presta 1.6.1.14, but I'm unsure when in the order flow the email is sent to Trustpilot? I believe the email is sent when the payment is fulfilled, which is the same time as the products are sent in my case.

 

i Already using mail allert module specifing the 2 emails but other problem is when a customer order  and then call to delete the order. the trustpilot email (order confirmation) is already sent.

The only solution is to send a trustpilot email when you change order status to "shipped", because you are sure that customer is waiting and payed it :)

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

I'm using mail alerts v3.6.1.

 

I tried updating mailalerts.php with the above changes but it failed to work.

 

To allow trustpilot afs to work I need the customer email to be in the 'to' field and trustpilot email in the BCC. By adding the above BCC I think trustpilots automatic feedback email will be sent to the admin email rather than the customer.

 

I thought it would be straightforward to use trustpilot afs but has proven more difficult than I thought.

 

Thanks for the help. Any other ideas?

 

the new system need to read a specific code inside the email template:

<script type="application/json+trustpilot">

{

"recipientEmail": "CUSTOMER EMAIL",

"recipientName": "CUSTOMER NAME",

"referenceId": "ORDER ID"

}

</script>
Link to comment
Share on other sites

  • 11 months later...
On ‎2017‎年‎6‎月‎17‎日 at 7:00 AM, grumpyomg said:

Got the trustpilot AFS to work in version 1.6.1.9 using the help above.

 

In the PaymentModule.php class find this code.


                        if (Validate::isEmail($this->context->customer->email)) {
                            Mail::Send(
                                (int)$order->id_lang,
                                'order_conf',
                                Mail::l('Order confirmation', (int)$order->id_lang),
                                $data,
                                $this->context->customer->email,
                                $this->context->customer->firstname.' '.$this->context->customer->lastname,
                                null,
                                null,
                                $file_attachement,
                                null, _PS_MAIL_DIR_, false, (int)$order->id_shop
                            );

and replace with


                        if (Validate::isEmail($this->context->customer->email)) {
                            Mail::Send(
                                (int)$order->id_lang,
                                'order_conf',
                                Mail::l('Order confirmation', (int)$order->id_lang),
                                $data,
                                $this->context->customer->email,
                                $this->context->customer->firstname.' '.$this->context->customer->lastname,
                                null,
                                null,
                                $file_attachement,
                                null, _PS_MAIL_DIR_, false, (int)$order->id_shop,
				'*********@invite.trustpilot.com'
                            );

Replacing the ********* with your trustpilot AFS address.

 

Hi, 

I have updated the class with my email to send as BCC. It seems to work: I see the mail being logged as "sent", but I don't receive anything. The order confirmation mail is properly sent so it is not a problem of mailer. 

any idea ?

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

  • 5 years later...
On 6/17/2017 at 12:00 AM, grumpyomg said:

Got the trustpilot AFS to work in version 1.6.1.9 using the help above.

 

In the PaymentModule.php class find this code.

                        if (Validate::isEmail($this->context->customer->email)) {
                            Mail::Send(
                                (int)$order->id_lang,
                                'order_conf',
                                Mail::l('Order confirmation', (int)$order->id_lang),
                                $data,
                                $this->context->customer->email,
                                $this->context->customer->firstname.' '.$this->context->customer->lastname,
                                null,
                                null,
                                $file_attachement,
                                null, _PS_MAIL_DIR_, false, (int)$order->id_shop
                            );

and replace with

                        if (Validate::isEmail($this->context->customer->email)) {
                            Mail::Send(
                                (int)$order->id_lang,
                                'order_conf',
                                Mail::l('Order confirmation', (int)$order->id_lang),
                                $data,
                                $this->context->customer->email,
                                $this->context->customer->firstname.' '.$this->context->customer->lastname,
                                null,
                                null,
                                $file_attachement,
                                null, _PS_MAIL_DIR_, false, (int)$order->id_shop,
				'*********@invite.trustpilot.com'
                            );

Replacing the ********* with your trustpilot AFS address.

 

This still works as of 2023. Much much thanks!

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