<p>You could do this with a small plugin that listened to the Guest Entries <a href="https://github.com/craftcms/guest-entries#the-aftersaveentry-event" rel="nofollow noreferrer">afterSaveEntry</a> event.</p>

<p>The logic would look something like this:</p>

<pre><code>use craft\guestentries\controllers\SaveController;
use craft\guestentries\events\SaveEvent;
use yii\base\Event;

// ...

Event::on(SaveController::class, SaveController::EVENT_AFTER_SAVE_ENTRY, function(SaveEvent $e) {
    // Grab the entry
    $entry = $e-&gt;entry;

    // Assuming `toEmail` is a custom field on the entry.
    Craft::$app-&gt;getMailer()-&gt;compose()
        -&gt;setSubject('Thanks for your submission!')
        -&gt;setTextBody('You are amazing.')
        -&gt;setTo($entry-&gt;toEmail)
        -&gt;send();
});
</code></pre>

<p>You can generate Craft 3 boilerplate plugin code using <a href="https://pluginfactory.io" rel="nofollow noreferrer">https://pluginfactory.io/</a> and the official Craft 3 Plugin docs are here: <a href="https://docs.craftcms.com/v3/extend/plugin-guide.html" rel="nofollow noreferrer">https://docs.craftcms.com/v3/extend/plugin-guide.html</a></p>

CC BY-SA 4.0
2018-08-14T22:41:22.560Z
2018-08-14T22:41:22.560Z
Brad Bell
<p>I use Guest Entries plugin to add information, and I need to send some message to user who filled the form to email. Can you show me an example of how I can do this?</p>

CC BY-SA 4.0
2018-08-13T03:32:53.670Z
Is this Guest Entries 1 for Craft 2 or Guest Entries 2 for Craft 3?
Brad Bell
CC BY-SA 4.0
2018-08-13T05:58:43.370Z
it is Guest Entries 2 for Craft 3
Alex Ryhluk
<plugin-guestentries>
Guest Entries - How I can send message to user after saving form information
# Guest Entries - How I can send message to user after saving form information

(Asked by: username_0 on 2018-08-12)

I use Guest Entries plugin to add information, and I need to send some message to user who filled the form to email. Can you show me an example of how I can do this?

**Tags:** plugin-guestentries

> **Comments:**
> **username_1**: Is this Guest Entries 1 for Craft 2 or Guest Entries 2 for Craft 3?  
> **username_0**: it is Guest Entries 2 for Craft 3  

---

## 1 answers

### Answer by username_1 on 2018-08-14. Score: 1

You could do this with a small plugin that listened to the Guest Entries afterSaveEntry event.
The logic would look something like this:
use craft\guestentries\controllers\SaveController;
use craft\guestentries\events\SaveEvent;
use yii\base\Event;

// ...

Event::on(SaveController::class, SaveController::EVENT_AFTER_SAVE_ENTRY, function(SaveEvent $e) {
    // Grab the entry
    $entry = $e->entry;

    // Assuming `toEmail` is a custom field on the entry.
    Craft::$app->getMailer()->compose()
        ->setSubject('Thanks for your submission!')
        ->setTextBody('You are amazing.')
        ->setTo($entry->toEmail)
        ->send();
});

You can generate Craft 3 boilerplate plugin code using https://pluginfactory.io/ and the official Craft 3 Plugin docs are here: https://docs.craftcms.com/v3/extend/plugin-guide.html


---

