# doppelte Ordermail bei Backend Bestellugen SW Plugin

**URL:** https://forum.shopware.com/t/doppelte-ordermail-bei-backend-bestellugen-sw-plugin/34018
**Category:** Programmierung
**Created:** [28. Januar 2016 um 15:49 UTC](https://forum.shopware.com/t/doppelte-ordermail-bei-backend-bestellugen-sw-plugin/34018 "2016-01-28T15:49:15Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Creatixx](https://avatars.discourse-cdn.com/v4/letter/c/c67d28/32.png) [@Creatixx](https://forum.shopware.com/u/Creatixx)
#### Post date: [28. Januar 2016 um 15:49 UTC](https://forum.shopware.com/t/doppelte-ordermail-bei-backend-bestellugen-sw-plugin/34018/1 "2016-01-28T15:49:15Z")

</div>

Hallo,

wer das Plugin Backend Bestellungen von SW einsetzt, der hat das Problem das die Bestellbestätigungsmail **2 mal** an den Kunden gesendet wird.

Als Beispiel:  
erste Mail: [kunde@kundenmail.de](mailto:kunde@kundenmail.de)  
zweite Mail: [kunde@kundenmail.de](mailto:kunde@kundenmail.de), [office@meinshop.de](mailto:office@meinshop.de)

Also einmal Kundenemailadresse und einmal die, die in der Konfiguration des Shops hinterlegt ist.

Dazu gibt es seit längerem auch dieses [Ticket PT-3960](https://issues.shopware.com/#/issues/PT-3960?status=1&status=3&status=10001&status=4&status=10010&status=10025&status=10017&plugin=BackendOrder&projects=PT). **Vielleicht können hier ein paar voten um das Ganze etwas zu priorisieren!**

Zuständig dafür ist die folgende Funktion unter  
Pfad: /engine/Shopware/Plugins/Community/Backend/SwagBackendOrder/Controllers/Backend/SwagBackendOrder.php

```
private function sendOrderConfirmationMail($orderModel)
    {
        $context = $this->prepareOrderConfirmationMailData($orderModel);
        $context['sOrderDetails'] = $this->prepareOrderDetailsConfirmationMailData($orderModel);

        $mail = Shopware()->TemplateMail()->createMail('sORDER', $context);
        $mail->addTo($context["additional"]["user"]["email"]);
        $mail->send();

        //If configured send an email to the shop owner
        $mailNotToShopOwner = Shopware()->Config()->get('no_order_mail');
        if (!$mailNotToShopOwner) {
            $mail->addTo(Shopware()->Config()->get('mail'));
            $mail->send();
        }
    }

```

Ich habe nun folgendes im unteren Teil in der if Anweisung zusätzlich eingefügt:

```
        $mail = Shopware()->TemplateMail()->createMail('sORDER', $context);

```

Dadurch werden die eMails wieder korrekt versendet. Eine an den Shopadmin und eine an den Kunden. **Die Frage ist aber ob dieser Weg so ok ist, oder ob es hier eine bessere Vorgehensweise gibt?!**

Hier der komplette Code:

```
    private function sendOrderConfirmationMail($orderModel)
    {
        $context = $this->prepareOrderConfirmationMailData($orderModel);
        $context['sOrderDetails'] = $this->prepareOrderDetailsConfirmationMailData($orderModel);

        $mail = Shopware()->TemplateMail()->createMail('sORDER', $context);
        $mail->addTo($context["additional"]["user"]["email"]);
        $mail->send();

        //If configured send an email to the shop owner
        $mailNotToShopOwner = Shopware()->Config()->get('no_order_mail');
        if (!$mailNotToShopOwner) {
            $mail = Shopware()->TemplateMail()->createMail('sORDER', $context);
            $mail->addTo(Shopware()->Config()->get('mail'));
            $mail->send();
        }
    }

```

Gruß Creatixx

&nbsp;

//edit:DN: Hier geht es weiter:&nbsp;[http://forum.shopware.com/discussion/comment/150186/#Comment\_150186](http://forum.shopware.com/discussion/comment/150186/#Comment_150186)
