getgrav / grav-plugin-email

Grav Email Plugin
http://getgrav.org
MIT License
37 stars 29 forks source link

I need to send two types messages while submitting form #59

Closed geogeorgejoseph closed 7 years ago

geogeorgejoseph commented 7 years ago

In my form i have one email field.After submitting the form i need to send confirmation mail of mail to that user and need to send the notification message to that particular organization.

For example organization id : A@gmail.com user id : B@gmail.com

After submission

one mail to B@gmail.com

thanks for registering.....

another mail to A@gmail.com

An enquiry has been made by B.

Please suggest a solution for this?

rhukster commented 7 years ago

I've not tried it myself, but I don't see why you couldn't have two email actions in the process: section of the form. have you tried that?

geogeorgejoseph commented 7 years ago

i try to do that.

geogeorgejoseph commented 7 years ago

Finally i got the solution for this. I use below code to send two types of mail to each email id's.

process:
    -
        email:
            subject: 'Form Submission'
            from: '{{ config.plugins.email.from }}'
            to: ['{{ config.plugins.email.from }}']
            body: '{% include ''forms/data.html.twig'' %}'
    -
        email:
            subject: '{{ form.value.name|e }}'
            from: '{{ config.plugins.email.from }}'
            to: ['{{ form.value.email }}']
            body: '{% include ''forms/data1.html.twig'' %}' 
rhukster commented 7 years ago

I assumed it would work, glad that it does.

NicoHood commented 3 years ago

I current have the same issue when trying to send multiple emails:

Expected response code 250 but got code "451", with message "451 4.7.1 Service unavailable - try again later "

It always happens when I try to send more than one email in a single website action (form submit for example). I tried to send the email via form process action (as mentioned about) and also via the plugin code itself ($this->grav['Email']->send($message);). I even added a delay of 20 seconds with sleep(20), but that did not help.

If only send one email, but reload the page and send the form data again two emails will be sent. Meaning there is no throttling on the smtp server side.

I am really wondering what causes the issue, maybe the connection for that website call/thread is still kept open and that causes the issue to pop up on the second email? Similar issue issue2

NicoHood commented 3 years ago

Update: I contacted my hoster (netcup), send him some logs and he finally managed to solve the issue on his side. I asked for more details, if possible, and will edit them here once I know more.

Edit: The hoster support is not allowed to name any details. Something in their mailserver was configured wrong.