If no style is defined this error e thrown when sending the mail. The mail is sent without any problem, but the message is presented to the user.

This happens if in the Mime Mail configuration the "Include site style sheets" combo isn't checked and you don't provide any other.

I also found the solution, but still trying to work with GIT to create a patch file. But here's the code :

File : mimemail.theme.inc
Patch :
«
@@ -86,10 +86,12 @@

// Process each style sheet.
$css = '';
- foreach (explode("\n", $styles) as $style) {
- if (!empty($style) && @file_exists($style)) {
- $css .= @file_get_contents($style);
- }
+ if (isset($styles)) {
+ foreach (explode("\n", $styles) as $style) {
+ if (!empty($style) && @file_exists($style)) {
+ $css .= @file_get_contents($style);
+ }
+ }
}

// Regexp to match comment blocks.
»

Comments

sgabe’s picture

Title: Notice: Undefined variable: styles in template_preprocess_mimemail_message() » Check if $styles is set
Priority: Normal » Minor
StatusFileSize
new2.91 KB

I would go further, since the CSS optimization also unnecessary when no style is defined.

sgabe’s picture

Status: Active » Needs review

Changing status.

carn1x’s picture

Manually applied patch in #1, seems to be working fine.

sgabe’s picture

carn1x’s picture

Manual application of patch in #4 works fine thanks :)

luti’s picture

Applied the patch #4 to the latest 7.x-1.x-dev (2011-Sep-17), but still getting the same errors (when requesting a new password, after clicking "E-mail new password"...):

  • Notice: Undefined variable: css in include() (line 24 of .../mimemail/theme/mimemail-message.tpl.php).
  • Notice: Undefined offset: 2 in mimemail_compress_clean_message() (line 16 of .../mimemail/modules/mimemail_compress/mimemail_compress.inc).
  • Notice: Undefined offset: 0 in mimemail_compress_clean_message() (line 20 of .../mimemail/modules/mimemail_compress/mimemail_compress.inc).
ibes’s picture

patch in #4 works for me

LUTi in #6 has enabled the module "Mime Mail CSS Compressor". This submodule of mimemail searches (preg_match) for css in the mail text, seperates it from the rest of the mail and compress it.
If there is no "

" in the mail - like it is, in our case - there are no results of the search (preg_match) and so the script give back a notice. I am not quite sure how to skip the Compressor, when there is no css in the message. Is there a way to disable the module if the "Include site style sheets " checkbox is unchecked?
sgabe’s picture

Status: Needs review » Needs work

Then this needs a little more work.

sgabe’s picture

Status: Needs work » Needs review
StatusFileSize
new4.76 KB

I am attaching a revised patch according to LUTi's reply.

ibes’s picture

I did this test without the patch (errors as reported) and with the patch (no errors, everything like expected)

(the versions drush loads by default)
- webform (send html mail with attachment)
- rules (send html mail)
- simplenews (send html newsletter)
- hook_mail_alter() in my own module

works with and without stylesheets

In my opinion the patch of #9 works

sgabe’s picture

Status: Needs review » Fixed

Thanks ibes for testing. I did also some testing and the patch seems to solve the issue.

Status: Fixed » Closed (fixed)

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