Hello,
I had this error testing conditionals with Webform 7.x-4.0-alpha8 :
Notice: Undefined index: name@example.com in webform_submission_send_mail() (line 236 of /path_to_drupal_site/sites/all/modules/contrib/webform/includes/webform.submissions.inc).
Warning: Invalid argument supplied for foreach() in webform_submission_send_mail() (line 236 of /path_to_drupal_site/sites/all/modules/contrib/webform/includes/webform.submissions.inc).
Steps to repeat:
- configure a Select options type component
- positionning this component as the first one
- setting "E-mails to" with a custom address
In the email settings page, "E-mail to address > Component", you should see as first choice the "Select options type component".
This page has to be saved with the select list in first position. Then you will have the empty [email_mapping] array appear in $emails array when testing (webform.submissions.inc file -> attached file)
Empty [email_mapping] array doesn't appear and mails are sent if I choose another mail component (a Textfield for example) in the "E-mail to address" zone, even if "Component" radio button isn't checked
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | webform.emails.txt | 26.21 KB | vako |
| #11 | webform.emails.txt | 26.4 KB | vako |
| #8 | webform_conditional_email_warning-2028949.patch | 638 bytes | quicksketch |
| Capture d’écran 2013-06-26 à 19.37.13.png | 11.83 KB | Michael_F | |
| Capture d’écran 2013-06-26 à 19.36.18.png | 19.58 KB | Michael_F |
Comments
Comment #1
bjcooper commentedI just beat my head on my desk all morning with this problem, but I think I've found--and corrected, no less--the issue!
It seems that when saving email notification settings, the 'extra' column (used for storing information about component email mappings) isn't getting properly emptied when using a custom email address.
Line 518 of the
webform_email_edit_form_submit()function is to blame, I believe.When
$field = 'email'and$option = 'custom', this line still adds any information in the field mapping elements to the 'extra' array if$form_state['values']['email_component']is numeric. Really, it shouldn't be checking 'email_component' if we've chosen to use 'email_custom'.The side effects are that
webform_email_edit_form_submit()populates$email['extra']with information from the field mapping elements. Thenwebform_email_insert()orwebform_email_update()writes that 'extra' data to the DB. Later, whenwebform_submission_send_mail()wants to send the notification, it simply checks that$email['extra']is set (line 234 ofwebform.submission.inc), sees that it is, and tries to populate the email 'To' field from a whatever random info is sitting in$email['extra'].My solution is simply to change line 518 of
webform_email_edit_form_submit()from this:$cid = $form_state['values'][$field . '_component'];To this:
$cid = $form_state['values'][$field . '_' . $option];Then 'email_component' is ignored when
$option = 'custom'.EDIT
You must also re-save the email settings for any Webform email that should use a custom email address but has data in the 'extra' column of 'webform_emails'. For me, this was all the emails I edited after upgrading Webform to 7.x-4.0.
The patch above should keep bad data from being written to the DB when saving email settings, but won't do anything unless you re-submit '/node/%nid/webform/emails/%eid'. Alternately, you could probably remove the data in the 'extra' column of 'webform_emails' for any record where 'email' is an email address instead of a component id. Don't alter the DB directly if you don't know what you're doing.
Comment #2
Jrosborough commentedI have the same issue, attempted the fix in comment #1 with no change.
Comment #3
bjcooper commentedLet's set the Status back to active, since the suggested fix doesn't seem to work for everybody.
Comment #4
ebren commentedI'm suffering the exact same problem. Solution #1 did NOT work for me either.
Comment #5
bjcooper commentedSee my edit on the original post.
I forgot to mention that, after making the changes, you must re-submit the webform email settings form so the faulty 'extra' information gets cleared out. I believe you could also just go into the DB table and empty out the 'extra' column instead.
The whole point of the patch was to save the correct data on form submission, so the patch changes won't do anything for you unless you resubmit the email edit form.
Comment #6
bjcooper commentedLet's see if the patch works with that added bit of instruction.
Comment #7
bartmann commentedI swapped that line and re-submit the webform email settings == success.
Comment #8
quicksketchThanks guys, excellent report, sleuthing, and solution. I reproduced the problem exactly as described by the original poster and fixed the problem as @bjcooper reported. I've committed this patch to fix the problem per his recommendation.
Comment #9
hass commentedNitpicking, but there is a trailing space...
Comment #10
othermachines commentedGeez, and I just downloaded 7.x-4.0-alpha8 yesterday.
Patch provides a most excellent fix. Thanks.
Comment #11
vako commentedThe patch didn't work for me. Please take a look at the attached file if it has been applied properly.
Comment #12
vako commentedI patched it again using Cygwin and manually with the same results.
Comment #13
quicksketch@Vako: Can you try just using the alpha9 version that came out a few days ago? It includes this fix.
Comment #14
vako commentedI deleted the folder and copied over alpha9 version. Cleared the cache and got the same error.
Here are some info that might help:
Using Drupal 7.22
Webform 7.x-4.0-alpha9
Webform Report 7.x-1.0
Webform Share 7.x-1.2
Theme is Zircon
Comment #15
vako commented>>Solved<<
The solution was to delete the email setting and recreate it. Now everything's working fine. thank you!!
Comment #16
quicksketchAh yes, I think you could also just re-save the existing form and that would work also.
Comment #17
hass commentedSounds like an update hook need to fix this.
Comment #18
scotthorn commentedI don't believe the alpha10 release included an update hook for this, is it still planned? I would be happy to help code it, but I'm not familiar enough with Webform's internals to tackle the whole thing. Can anyone shed some light on what db problem is fixed by deleting the email settings and re-enabling?
Comment #19
quicksketchWith less than 0.1% of Webform installs running alpha8 at this point, I don't think we're likely to include an update that fixes this issue for users who were running that particular version. Resaving the e-mail settings can solve this problem for that limited number of users.