1

Topic: Verification form 4 - how to send email

Hi,

I have set up Verification form 4 but the email options are not working. The "Contact another expert" or "Contact recorder" both display a "The email was sent successfully" message but no email is received. My drupal site can send other emails via the contact forms, the warehouse configuration issues section doesn't have any messages about email, and the warehouse log doesn't have error messages either.

Is there some other setting/s I need to configure?

Thanks, Alice

2

Re: Verification form 4 - how to send email

Hi

I'm looking at the code and can see that the sending of these emails is done using Ajax.

The iform/client_helpers/prebuilt_forms/js/verification_4.js script has a sendEmail() function which hands the email to the server which processes it using the ajax_email() function in iform/client_helpers/prebuilt_forms/verification_4.php

The server responds with 'OK' or 'Fail' according to whether it thinks the mail has been sent. You should be able to use browser tools to inspect this network exchange. Ensure the information about the email looks sensible. If you are getting "The email was sent successfully" message this indicates that the server responded with 'OK'.

As the PHP documentation says, the mail() function used by the iform module "Returns TRUE if the mail was successfully accepted for delivery, FALSE otherwise. It is important to note that just because the mail was accepted for delivery, it does NOT mean the mail will actually reach the intended destination."

This function sends mail according to configuration settings in php.ini which is also the default Drupal behaviour. It is possible to use other mail-sending methods in Drupal e.g. by using a module like https://www.drupal.org/project/smtp. Do you do anything like that? If so, it could explain why Drupal can send email but the iform module is failing.

Jim Bacon.

3

Re: Verification form 4 - how to send email

Hi Jim,

Thanks for your reply. I have been checking this out today, and I saw in firebug that the server does indeed respond with "OK" even though the mail doesn't send. I need to check the php.ini file but I don't have direct access to it (I have asked my server tech guy). The other email options on my site are just using the normal drupal defaults (and working correctly) which is why I thought the verification 4 should also just work out of the box. I'll see if the technical person can shed any light on it.

Alice

4

Re: Verification form 4 - how to send email

Hi Alice,

If you go to the Drupal menu item Reports>Status Report (admin/reports/status), scroll down to the PHP entry and click the more information link (admin/reports/status/php) you get to see the php.ini settings.

Perhaps there would be a mail server log to explain why the messages aren't being sent.

Jim Bacon

5 (edited by namwebs 01-06-2016 08:59:34)

Re: Verification form 4 - how to send email

I have fixed this.

In this file \sites\all\modules\iform\client_helpers\prebuilt_forms\verification_4.php in the function public static function ajax_email() the wordwrap on the $emailBody was somehow causing a problem. Changing wordwrap($emailBody, 70) to $emailBody fixes this and allows the email to send. Since this is just code to format the body text there presumably shouldn't be any negative effects.

Thanks, Jim, for your help.

Alice

6

Re: Verification form 4 - how to send email

Hi

The reason for word-wrapping is to meet the specification for email and is not just about human readability so there could be negative effects. (Note, because it is an html message, to introduce line breaks for human readability we would have to use '<br/>' instead of the \n which is actually being used.)

The PHP documentation says of the body text that "Each line should be separated with a CRLF (\r\n). Lines should not be larger than 70 characters."

Is your problem also resolved by

wordwrap($emailBody, 70, "\r\n")

There also seems to be variability depending on the message transfer agent
http://php.net/manual/en/function.mail.php#52856
http://php.net/manual/en/function.mail.php#59773

Looking at the way Drupal does it, I see the comment

Note: e-mail uses CRLF for line-endings. PHP's API requires LF on Unix and CRLF on Windows. Drupal automatically guesses the line-ending format appropriate for your system.

Quite a muddle!

Jim Bacon.

7 (edited by namwebs 01-06-2016 11:34:27)

Re: Verification form 4 - how to send email

Yup, that works too.

Thanks.