When I enabled ajax on my webform setting page, the email that is send after you complete the webform, isn't always send.
It gives no errors, also in the watchdog says the email is send succesful. But it isn't.

Does anyone know how this is possible?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Dennis Cohn created an issue. See original summary.

jrockowitz’s picture

Are you using any email handling modules?

Is the email sent with Ajax off?

Are any errors being logged in your browsers JavaScript console?

Are you able to replicate this issue using the default contact form?

Dennis Cohn’s picture

Are you using any email handling modules?
No, do I need something like swiftmailer?

Is the email sent with Ajax off?
Yes

Are any errors being logged in your browsers JavaScript console?
No, also no errors in the logs.

Are you able to replicate this issue using the default contact form?
We don't have the contact form enabled.

jrockowitz’s picture

My steps attempting to reproduce this issue using the default 'Contact' webform.

  • Enable and configure SMTP module /admin/config/system/smtp
  • Goto /admin/structure/webform/manage/contact/settings
  • Enable Ajax
  • Goto /webform/contact/test
  • Click 'Submit'
  • Check Recent log messages /admin/reports/dblog
  • Confirm Email receive

Does your "Recent log messages" contain a record saying "Sending mail to: someone@gmail.com"?

Dennis Cohn’s picture

Well I'm using the contact form I see and in the logs I see: "Contact webform sent Email notification email" after testing the form.

I tried to fill in the form on 6 different pages and I got different results.
Sometimes, 5 of the 6 emails are received... sometimes 3 of 4.
While the logs says: "Contact webform sent Email notification email."

The only time it works all the time is when I enable "Inline (reloads the current page and replaces the webform with the confirmation message)" as comformation type.

Can It be the hosting?

jrockowitz’s picture

Are you submitting the form as an anonymous or authenticated user?

If you are consistently seeing the sent message in watchdog but then not receiving the email, I am willing to say that the problem is not the Webform module.

Have you tried using a different SMTP server? I am using gmail.

Dennis Cohn’s picture

I'm testing the form as an anonymous and authenticated user but the result is the same.
It's so strange... no errors, nothing. I'm kinda lost :)

Haven't tried it with an other SMTP server..

jrockowitz’s picture

@Dennis Cohn Is anything being logged in the browser's JS console. When Ajax fails there should always be something logged in the browser's JS console.

A Gmail SMTP server is really easy to setup.

Dennis Cohn’s picture

After some testing and contacting the webhosting to dug into some mail logs they found out that the mails were being blocked by the spamfilter and therefor not being delivered.

They send me this example.

pts rule name              description
---- ---------------------- --------------------------------------------------

 0.0 HTML_MESSAGE           BODY: HTML included in message
 1.1 MIME_HTML_ONLY         BODY: Message only has text/html MIME parts
 1.3 RCVD_IN_RP_RNBL        RBL: Relay in RNBL,
 0.6 HTML_MIME_NO_HTML_TAG  HTML-only message, but there is no HTML tag

or

FORGED_YAHOO_RCVD=1.63, 
HTML_MIME_NO_HTML_TAG=0.377
MIME_HTML_ONLY=0.723
TO_NO_BRKTS_HTML_ONLY=1.647

So it's not a bug I think?
Well I think there should be a nice default html template which has got the right mail headers for none technical people.. :)

jrockowitz’s picture

Would the solution be as simple as adding basic <html> tags to webform-email-message-html.html.twig?

The attached patch applies a full HTML table to the message. This patch is going to break a few tests but you should be able to test it.

<html>
<head>
  <title>{{ message.subject }}</title>
</head>
<body>
{{ message.body }}
</body>
</html>
jrockowitz’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 10: 2992209-11.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

jrockowitz’s picture

Status: Needs work » Needs review
FileSize
3.33 KB

  • jrockowitz committed 711d234 on 8.x-5.x
    Issue #2992209 by jrockowitz: When Ajax is enabled, mail isn't always...
jrockowitz’s picture

Status: Needs review » Fixed

I committed the patch. Please download the latest dev release to review.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.