email sent, but background is blue

maui1 - February 23, 2007 - 03:19
Project:Mime Mail
Version:5.x-1.x-dev
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:closed
Description

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.

#1

greggles - February 24, 2007 - 18:46

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.

#2

liquidcms - November 18, 2007 - 23:56
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.

#3

Allie Micka - February 19, 2008 - 00:28
Project:Send» Mime Mail
Version:5.x-1.x-dev» 5.x-1.x-dev
Category:bug report» support request

#4

fuquam - May 20, 2008 - 20:47

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.

#5

Digital Deployment - May 30, 2008 - 21:34

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

#6

cozzi - June 1, 2008 - 11:57

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.

#7

fuquam - June 2, 2008 - 02:52

I couldn't agree more.

#8

highfly - June 10, 2008 - 10:44

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.

#9

epicflux - July 2, 2008 - 20:27

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

<?php
/**
* 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.

#10

Gef - July 8, 2008 - 10:34

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.

#11

dwils03 - July 10, 2008 - 15:01

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.

#12

dwils03 - July 11, 2008 - 13:43

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.

#13

Allie Micka - July 10, 2008 - 15:53

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.

#14

epicflux - July 24, 2008 - 14:09

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)

#15

sime - July 17, 2008 - 03:44

epicflux, sweet link :)

#16

Gef - July 25, 2008 - 15:46

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.

#17

Allie Micka - July 25, 2008 - 16:00

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

#18

Gef - July 28, 2008 - 10:15

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.

#19

jerdavis - August 6, 2008 - 05:56
Status:active» closed

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!

#20

aryam8 - August 20, 2008 - 11:14

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-

 
 

Drupal is a registered trademark of Dries Buytaert.