In essence, if you have "Send as HTML" unchecked, and "Send as BCC" unchecked, and you don't have any file attachments, mass_contact fails to properly initialize $headers, so drupal_mail doesn't work.
Drupal Version: 5.2, Linux.
To reproduce bug:
- Choose "Mass Contact" from the navigation menu.
- Specify any Subject.
- Specify any Category.
- Specify any Message. E.g., "delete me".
- Do *NOT* include an attachment.
- UNcheck "Send as HTML"
- UNcheck "Send as BCC"
- I added
var_dump($headers);exitto includes/common.inc/~1941 so I could see what was going on inside ofdrupal_mail.
Findings
$headers is NULL in this situation.
By contrast, the expected contents of $headers is at a minimum array(0){}
The result of $headers being NULL is that the array_merge in drupal_mail at includes/common.inc/~1941 fails, and a warning message is generated. When you have NULL headers, no mail is sent.
Suggested Fixes
Either of these two fixes worked fine for me:
1. Initialize $headers = array() just after the "// create headers" comment at modules/mass_contact/~671. [Relies on drupal_mail's $defaults array to set the Content-Type to text/plain]
or
2. Ensure that $headers is at least initialized to text/plain (modules/mass_contact/~687):
elseif ($form_values['html'] == 1) {
$headers['Content-Type'] = 'text/html; charset=UTF-8; format=flowed'; }
# add the following:
elseif ($form_values['html'] == 0) {
$headers['Content-Type'] = 'text/plain; charset=UTF-8; format=flowed';
}
Either way, I get reasonable headers, and mail sends! Hooray!
NOTE: I realize there might be something about my php.ini file that might help, too. But it's a good idea to fix this for all those people who's php.ini file is like mine...
-Andy
Comments
Comment #1
oadaeh commentedDo you have the following code from line 871 to line 877?
Comment #2
oadaeh commentedI found two places where I do not check for a valid header, and they're both in the area where a limit on the number of recipients is placed. This will be corrected soon.
Comment #3
oadaeh commentedComment #4
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.