Hi Sime, I've diagnosed and fixed the following:
When creating an html message the user is able to enter a plain text alternative in one of the fields. When the mail is sent this plain text alternative isn't sent with the message. This only occurs when the message is specified as html.
The reason this occurs is that the mimemail function expects one of two parameters, either a plaintext string or a NULL value so that mimemail can auto-generate a plaintext alternative. The mailout code puts a empty string value in there which overrides any auto-generation functionality. The fix is to check to see whether the plaintext field in the form has any data and if so provide it to the mimemail function, if not allow mimemail to auto-generate its own.
As requested here is the code, rather than a patch (how un-Drupal of me, I feel naughty!):
// Send mail
if (!$data['user_html'] || !$data['html']) {
// If either the user or the email is plain text, then send in plain text.
$success = mimemail($data['email_from'], $data['email_to'], $data['email_subject'], $final_email_body, TRUE, array(), $final_plain);
}
else {
if ($data['email_plain']) {
$success = mimemail($data['email_from'], $data['email_to'], $data['email_subject'], $final_email_body, FALSE, array(), $final_plain, unserialize($data['attachments']));
}
else {
$success = mimemail($data['email_from'], $data['email_to'], $data['email_subject'], $final_email_body, FALSE, array(), NULL, unserialize($data['attachments']));
}
}
Comments
Comment #1
simeLet me find my spanking stick... actually I'm a hack coder and so patches (unless exceedingly lengthy) don't help me half the time.