# Ich möchte E-Mail mit PHP senden

**URL:** <https://forum.shopware.com/t/ich-mochte-e-mail-mit-php-senden/58585>\
**Category:** Programmierung\
**Created:** [15. März 2019 um 07:42 UTC](https://forum.shopware.com/t/ich-mochte-e-mail-mit-php-senden/58585 "2019-03-15T07:42:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kane9x](https://avatars.discourse-cdn.com/v4/letter/k/258eb7/32.png) [@kane9x](https://forum.shopware.com/u/kane9x)\
**Post date:** [15. März 2019 um 07:42 UTC](https://forum.shopware.com/t/ich-mochte-e-mail-mit-php-senden/58585/1 "2019-03-15T07:42:51Z")

</div>

Ich möchte eine E-Mail in PHP senden, wenn der Benutzer das HTML-Formular ausgefüllt hat, und dann die Formularinformationen per E-Mail senden. Ich möchte das vom selben Webseiten-Anzeigeskript mit dem Formular machen.

Ich habe diesen Code gefunden, aber die Nachricht wurde nicht gesendet.

\<?php 

if (isset($\_POST['submit'])) { &nbsp; &nbsp; $to = $\_POST['email'];&nbsp; &nbsp; &nbsp; $subject = $\_POST['name']; &nbsp; &nbsp; $message = getRequestURI(); &nbsp; &nbsp; $from = "zenphoto@example.com"; &nbsp; &nbsp; $headers = "From:" . $from; &nbsp; &nbsp; if (mail($to, $subject, $message, $headers)) { &nbsp; &nbsp; &nbsp; &nbsp; echo "Mail Sent."; &nbsp; &nbsp; } &nbsp; &nbsp; else { &nbsp; &nbsp; &nbsp; &nbsp; echo "failed"; &nbsp; &nbsp; } } ?\\>

---

<div class="post-metadata">

**Author:** ![Moritz\_Naczenski](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/moritz_naczenski/32/7792_2.png) [@Moritz\_Naczenski](https://forum.shopware.com/u/Moritz_Naczenski)\
**Post date:** [15. März 2019 um 09:06 UTC](https://forum.shopware.com/t/ich-mochte-e-mail-mit-php-senden/58585/2 "2019-03-15T09:06:34Z")

</div>

Generell solltest du ein Plugin in Shopware umsetzen und deine eigene Mailvorlage anlegen. So kann man auch die Settings des Servers nutzen (wenn bspw. nur SMTP verfügbar ist). Hier hab ich mal ein Beispiel in einem Plugin geschrieben:&nbsp;[MNAddOrderNotification/MNAddOrderNotification.php at master · mnaczenski/MNAddOrderNotification · GitHub](https://github.com/mnaczenski/MNAddOrderNotification/blob/master/MNAddOrderNotification.php)

&nbsp;

&nbsp;
