The module works great for me on 4.7.6 but the emails all have a blue background obscurring some of the content. I tried setting bgcolor to white in the email template with no luck, is it hard coded somewhere in the module that I could change.

Comments

greggles’s picture

this is mostly likely related to your theme somwhere. I suggest you take a close review of the theme (particularly the body selector) and see if it is getting set in there.

I had this problem as well and it was a body selector that was overridden in the website by other elements, but in the emails it showed up and was confusing to me for a while. My background was tan, so I don't think that the blue is hardcoded anywhere, but just from your sites theme.

liquidcms’s picture

Version: 4.7.x-1.x-dev » 5.x-1.x-dev
Component: Miscellaneous » Code

yes, i agree that i think email css is theme css - would sure be nice to be able to override this somehow??? My background colour in black so obviously pretty hard to read the emails.

Allie Micka’s picture

Project: Send » Mime Mail
Category: bug » support
fuquam’s picture

Can you override the css doc that mime mail takes the formatting from? I don't want a blue background with tan links but I also don't want to disable mime mail. Should be easy but I can't figure out where to do it in the code.

Mac Clemmens’s picture

I've had this problem before...

I had a gray background in my theme's CSS file.

body {
background color: #CCC;
}

And no matter what I did to try and change it in the newsletter (the MIME module settings, the Sendmail, the newsletter, everything.) the darned thing would have a gray background when being read in outlook and some webmail programs (but not gmail or yahoo!).

I ended up having to change my body background to be white, and then had to add a DIV element in the theme to wrap everything, and I made the div's background gray.

body {
background-color: white;
}

#page-wrapper {
background-color: #CCC;
}

Hope this helps!
Mac

cozzi’s picture

I know I've requested similar functionality before, so I thought I might add a clarification (and continued support) to this request.

This is what I would think usable functionality would be:

In it's current form (meaning all emails get burdened with a great deal of CSS formating) this seems like added unneeded email overhead.

What I would think should take place for functionality is; there should be a check mark that enables the use of the theme css = [x] Use Theme CSS

A) If checked (and I don't know why one would) the email is sent as it is today. (using the Theme CSS and ignoring the email template)

B) If not checked the email would be sent using only the formating in the "email template" which is what I believe most would want (and expect) for default functionality.

fuquam’s picture

I couldn't agree more.

highfly’s picture

cozzi, ur request seems like a good one. I'm having all sorts of trouble trying to resolve the conflict between CSS and the emails sent through auto-responder right now.

epicflux’s picture

This theme function in the mimemail module gives you control over the styles included in your emails:

/**
 * Themeable message body
 */
function theme_mimemail_message($body, $mailkey = null) {
  $output = '<html><head>';
  $output .= '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';

  // attempt to include a mail-specific version of the css.
  // if you want smaller mail messages, add a mail.css file to your theme
  $styles = path_to_theme() .'/mail.css';

  $output .= '<style type="text/css"><!--';
  if (!file_exists($styles)) {
    // embed a version of all style definitions
    $styles = preg_replace('|<style.*"'. base_path() .'([^"]*)".*|', '\1', drupal_get$
  }
  foreach (explode("\n", $styles) as $style) {
    $output .= file_get_contents($style);
  }
  $output .= '--></style></head><body id="mimemail-body"><div id="center"><div id="ma$
  // compress output
  return preg_replace('/\s+|\n|\r|^\s|\s$/', ' ', $output);
}

Take notice of the check for the mail.css file in your theme folder.

Paul Lomax’s picture

Most webmail clients will strip out anything above and including the BODY tag so your nice stylesheet becomes useless anyway.

I'd put forward a suggestion to remove that function all together.

dwils03’s picture

I'm using the Mimemail module with the Workflows-ng module to send the full content of certain content types (blogs, photos) to certain email addresses. (Using Drupal 5.x and Mime 5.x-1.0) I'm glad that I finally found Mimemail as NOTHING else would deal with HTML.

The problem I have is related to this issue - my emails are being styled with the theme's css, which makes for a rather ugly email. This wouldn't be a huge problem except that it's also setting all the lines in my email body to center justification. Definitely unacceptable.

I'm not sure how to fix this. I understand that the mimemail.module contains the function listed above which checks for a mail.css style sheet, but it's also been said that this won't change anything in some email clients.

So what do I need to do to get the html formatting without the css? Or I suppose the other answer to the question is what needs to go in a mail.css file to override all of the site's formatting, just leaving the html-formatted text?

My css skills are minimal, so I'd need rather specific instructions (perhaps just a code snippet that I could throw in a mail.css file . . .)

Thanks in advance for your help.

dwils03’s picture

In case anyone was looking for a quick and dirty fix, I just included a blank mail.css file in my theme's folder. The result is an html-formatted, NON-STYLED email.

Allie Micka’s picture

The theme function attempts to suck in all of the theme's style sheets. This "usually" looks OK, but often needs work.

The main issue is usually the fact that your theme's CSS files are designed to render the entire page. So your boiled-down HTML might look like:

<body>
  <div id="content">
    <?php print $content ?>
  </div>
</body>

And your CSS might look like this:

body {
  background-color: black;
}

#content {
  background-color: white;
}

However, theme_mimemail_message, though it uses the same CSS, results in the following HTML:

<body id="mimemail-body">
  <?php print $content ?>
</body>

Thus, your background color is black ( per the body element ) but your message content is never rendered as white, because the message layout doesn't include your #content id.

You have 3 options:

  1. Add #mimemail-body to your CSS someplace, with appropriate defaults e.g.:
    #content, #mimemail-body {
      background-color: white;
    }
    
  2. Create a mail.css file. Usually, you can copy your theme's style.css and begin making appropriate changes. In addition to changing the "offensive" declarations, You can also remove a lot of unused styles ( e.g. sidebars ) so that the overall message weight is much lower.
  3. Override theme_mimemail_message() and do whatever you want. See http://drupal.org/node/55126 for information on how to do this.
epicflux’s picture

You could override that function completely by creating a phptemplate_mimemail_message in your template.php file, or in a custom module.

Code your function so it does not include any css file, or even so it doesn't include any <body> tag. Just have it return the body text if that's how you think it should work.

This function gives you the option to do what you think is right, and it should not be removed. Bravo to the authors for including this function.

A note too, the function I copied and pasted above is not the complete function as it got a little chopped off, so please don't work from that code, work from the function in your mimemail module file.

A Guide to CSS Support in Email.

(updated comment to link to the latest version of the CSS guide)

sime’s picture

epicflux, sweet link :)

Paul Lomax’s picture

Fact: Stylesheets in the <head> wont work in Hotmail or Gmail. So unless you plan to completely ignore those email clients (which make up a huge portion of the consumer market) then this function is completely useless and just adds extra complexity.

Allie Micka’s picture

Thanks for your input, Gef! While it's true that gmail and hotmail don't support css in the elements, this function adds a lot of value for the sites that do, with a minimum of configuration.

We're willing - and eager - to hear your recommended alternatives. ( see also: http://www.nabble.com/Re%3A-HTML-emails-p18493811.html )

Thanks!

Allie

Paul Lomax’s picture

To get HTML emails to work right in all clients, all styling needs to be done inline or in HTML 4. Its a mighty painful task, and it is like working with dark age technology but its the only way. Forget everything you know about semantics.

On that note, the only thing that could reliably be done is to parse all the styles pertaining to the body element and move them to an inline style on a container div.

Perhaps even pull out any 'base' styles, i.e link colours, h1 sizes etc. It might be too much work, but if your looking for a solution that should be it.

At the very least there should be an option in the mime mail config to not include the stylesheets.

jerdavis’s picture

Status: Active » Closed (fixed)

I've created a handbook page with the documentation from Allie's post #13 - If there are any further questions on this please let us know!

aryam8’s picture

I've posted on node http://drupal.org/node/145676#comment-971697
which has been marked as being a duplicate of this one (although I don't exactly think so).
Anyhow, I have changed my template to include the css styles in the and it works fine on gmail and my e-mail client (outlook 2007) but my hotmail and yahoo accounts only get my text version of the newsletter.

I've based my template on a template I downloaded from mailchip and that I used there to test - sending a test e-mail to my different accounts.
The email from this service appears in nice styled html while my e-mai (from my drupal site) does not come out right on hotmail nor yahoo.

The only difference I noticed was the encoding: The email from mailchip was encoded on base 8 (the html encoding) while the encoding by my drupal site (minemail) is done in base64.

Any comments will be greatly appreciated.
-M-

Delta Bridges’s picture

Hello Allie,
I have tried to put this on my theme css:

#content, #mimemail-body {<br>&nbsp; background-color: white;<br>}

But it doesn't work! emails are still being sent with the background blue colour of my site.

Did I do something wrong?
Thanks!

rvarkonyi’s picture

Hi,

reply to comment #11

How did you achieve to send the node body with workflow and mime mail? I'm fighting with this right now and all I only get an empty email body all the time. I tried using "send an email" action in workflow and also "execute custom php" with the mimemail($sender, $recipient, $subject, $body, $plaintext = NULL, $headers=array(), $text = NULL, $attachments = array(), $mailkey = '') function, but nothing seems to work.

Thanks!

Rob

TheoRichel’s picture

Having read the above I am only becoming more pessimistic that I will ever get my satisfying Simplenews_Template based layout back, which now is overruled by the new Mimemail since I once flipped the switch to send all messages as html. Of course I could switch it off, and as a matter of fact I did that, but it has no effect. I read somewhere that deleting the whole of Mimemail is also a way to obtain this. I need to uninstall several other modules for that, but I also did that and reinstalled everything. Problem doesnt disappear, messages remain distorted.

Please which css do i need to edit to get my layout back?

greggles’s picture

Please which css do i need to edit to get my layout back?

This is basically an impossible question to answer.

Or, it's possible, but the answers are not valuable - e.g. "You need to edit the one that is broken."

I can understand your frustration, but the underlying problem is the e-mail engine support for HTML/CSS and not these modules.

ratnesh aarohi’s picture

Version: 5.x-1.x-dev » 6.x-1.x-dev

I have two problems -
one the emails delivered carry an ugly background (a colour from my theme)
and two the emails are center aligned (instead of left aligned)

Tried adding

#content, #mimemail-body {
background-color: white;
}

this at the end of theme/tapestry/style.css
but that has not helped

Tried putting a blank mail.css (as per #11 above) in the theme/tapestry/ folder
but that also doesn't help

I do not have any PHP or CSS knwoeldge
Can somebody tell me how to get the background to be white and alignment to be "left" in all the ail clients

I'm using Mime Mail 6.x-1.x-dev and Simplenews 6.x-1.0-rc4

fuquam’s picture

I think creating a theme template for your web form is the only way around it. Once I created webform-mail-11.tpl.php I was able to format the webform data. I tried the mail.css too and that didn't do the trick.

ratnesh aarohi’s picture

Thanks for the quick reply
Is there a simple way to do this - creating "theme template"???
My knowledge of PHP & CSS is so basic that whatever i have read about theme template scares me.
Any place which has a step by step instructions to this?

fuquam’s picture

Look in the webform module folder for a file called THEMING.txt. It explains how its done. Pretty easy you just need to make sure the file is named correctly. Especially the correct node ID for your webform. webform-mail-[node id here].tpl.php

Delta Bridges’s picture

But this is not about the webform module, it is about simplenews.
Would you suggest to do the same?
Thanks

ratnesh aarohi’s picture

The README file of simple news gives the follwing options:

You can customize the theming of newsletters. Copy any of the *.tpl.php
files from the simplenews module directory to your theme directory. Both
general and by-newsletter theming can be performed.
The files are self documented listing all available variables.

When i copy the simplenews-newsletter-body.tpl.php to the theme directory and open to edit it - i find that i am woefully unskilled to do any theming. The above file reads as

* Available variables:
* - node: Newsletter node object
* - $body: Newsletter body (formatted as plain text or HTML)
* - $title: Node title
* - $language: Language object
*
* @see template_preprocess_simplenews_newsletter_body()
*/
?>

print $title;

print $body;
* Available variables:
* - node: Newsletter node object
* - $body: Newsletter body (formatted as plain text or HTML)
* - $title: Node title
* - $language: Language object
*
* @see template_preprocess_simplenews_newsletter_body()
*/
?>

print $title;

print $body;

Now i need somebody to help me with either a direct guide on how to code this file or any document which guides for the same.
Right now i want the background to be white
text to be center aligned
and the rest of the html formatting to be taken from the node itself.

ratnesh aarohi’s picture

I created mail.css and entered the following (ONLY) in that file and saved it in themes/mytheme/ folder.
But the back ground is still showing up.
Please note the email.css does not contain any other code - only the following text (this is becasue i want only the background colour to go away - the rest is fine)

/* done by geniekids*/

#content, #mimemail-body {
background-color: #FFFFFF;

}

Id there something I am doing wrong?

Delta Bridges’s picture

If you are using simplenews / mime and the background of the emails sent are blue, ten you can use the following module to get rid of the background colour:
http://drupal.org/project/simplenews_template

I have tested emails with:
gmail
hotmail
yahoo
outlook

Hope this helps :)

Delta Bridges

Jumoke’s picture

#mimemail-body {
  background-color: white;
}

This worked for me in my theme's css. Thank you Allie (post #13)

medicalmusings’s picture

Version: 6.x-1.x-dev » 7.x-1.0-alpha2

Drupal 7.17
Simplenews7.1,
Mimemail7.1a2
This is still an assue but adding this to the theme style.css seems to fix it. Would save hours of digging if a reference to this could be included in the readme.
Even better a checkbox in the configuration to ignore theme background as is done for some printer configurations?