my problem is that i cannot make the modules css field to work. simplenews is working correctly, altough simplenews templates 'header' and 'footer' capabilities are both working, however, wathever i type in the 'CSS' field for my newsletter it does not have any effect on the sent e-mails.

even the example provided in the documentation is not working.

i don't understand the thing totally, what does that mean that simplenews template includes my themes css? i can refer to classes defined in my themes style.css in the body of the newsletter? even this is not working.

Comments

mightyiam’s picture

For some reason, the developer chose to put the

tag inside the body instead of inside the head. i wonder why this is. Also, the paragraph with the link to unsubscribe in it, is put after the .
mightyiam’s picture

For some reason, the developer chose to put the style tag inside the body instead of inside the head. I wonder why this is. Also, the paragraph with the link to unsubscribe in it, is put after the /html.

dtabach’s picture

Moving the style tags to head did not do the trick. It's still being ignored.
Additionally, styles applied to different elements of the newsletter by Contemplate are lost when using this module (they are kept when the module is off).

jshuster@drupal.org’s picture

Here's what I'm using for CSS, and it works nicely. Navigate to your newsletter settings, select a newsletter, open the "Style" block, and paste something like this into the CSS field:

body {
   font-family: Verdana, Arial, sans;
   margin-left: 2em;
   margin-right: 2em;
   font-size: 10pt; 
}
p {
   font-size: 10pt;
}
h1 {
   font-size: 14pt;
}
h2 {
   font-size: 12pt;
}
h1,h2,h3,h4,h5 {
   color: #013466;
}
img {
   border:0;
   text-decoration:none;
}

The newsletter bodies are constructed using h1 and p tags by default (h1 for the title, and p for each paragraph). Thus, these style definitions explicitly set the styles for these tags.

Naturally, you can use other tags in the body of your newsletter issues. In which case, you'd want to define styles here for any tags you plan to use. In my case, I just use p, h1, and h2; and I use an img tag in the header.

This comes out looking very good in Thunderbird; I haven't tested it yet with Outlook, Gmail, etc.

I hope this helps ...

TBarregren’s picture

Assigned: TBarregren » Unassigned
Status: Closed (fixed) » Active

Respons to #1 and #2 by DawnLight and #3 by dtabach:

Many people checks e-mail with their web browser, such as with Yahoo!Mail, Hotmail, or Gmail. These web based client must of course strip out any <HTML>, <HEAD>, and <BODY> element within e-mails they are displaying. Otherwise those elements would interfere with the web page in which the e-mail is presented. Therefore, you should not have <STYLE> in the <HEADER> of a web mail. On the other hand, although it is not standard, most web browsers and mail clients accepts <STYLE> within the body. That's the reason for odd placement of the <STYLE>-element.

Designing a HTML-mail that can be displayed by as many mail clients as possible force you to accept a lot of dirty hacks and tricks. Putting the <STYLE>-element within the body is just one of them.

The default template used by Simplenews Template is careful crafted to be as useful as possible. It is based on the templates provided by MailChipmp. Other useful templates can be found at Campaign Monitor.

If you don't like the default template, you can easily replace it by overriding following themeable function the usually way:

/**
  * Themeable function for the HTML e-mail content.
  * Based on http://www.mailchimp.com/resources/templates/.
  */
function theme_simplenews_template_mail_content($content, $newsletter_name, $issue_title, $style, $bgcolor) {
	return <<<EOT
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
<TITLE>$newsletter_name: $issue_title</TITLE>
</HEAD>
<BODY bgcolor="$bgcolor">
<STYLE TYPE="text/css">
<!--
$style
-->
</STYLE>
<TABLE class="simplenews-template-background" width="100%" bgcolor="$bgcolor" cellpadding="0" cellspacing="0"><TR><TD valign="top" align="center">
<TABLE class="simplenews-template-content" cellpadding="0" cellspacing="0"><TR><TD>
$content
</TD></TR></TABLE>
</TD></TR></TABLE>
</BODY>
</HTML>
EOT;
}

For that case, you might find my e-mail bookmarks at Ma.gnolia useful.

TBarregren’s picture

Respons to #3 by dtabach:

Regarding your comment that "styles applied to different elements of the newsletter by Contemplate are lost when using this module". If you consider this a bug, please open a new issue and provide as detailed information as possible on your configuration, what you try to to accomplish and what's going wrong in doing so.

TBarregren’s picture

Assigned: Unassigned » TBarregren
Status: Active » Fixed

Respons to the original issue by aboros:

You ask "what does that mean that simplenews template includes my themes css?" Simplenews Template doesn't include your theme's CSS anywhere. The Simplenews Template module hooks the newsletter just before it is sent and pass it through a theming function. The default theming function is listed in #5 above. You can override it the usually way.

As seen from the signature of theme_simplenews_template_mail_content(), Simplenews Template provides several variables that can be used within the theming function. These are:

$content
The $content is the concatenation of the header provided in the Simplenews Template settings, the body of the newsletter (and nothing more!), and the footer provided in the Simplenews Template settings.
$newsletter_name
This is the name of the newsletter.
$issue_title
This is the title of the newsletter node.
$style
This is the style provided in the Simplenews Template settings.
$bgcolor
This is the background color in the Simplenews Template settings.

If you override theme_simplenews_template_mail_content(), it is entirely up to you what you do with these variables. :-) But if you choose to go with the default imlementation (as seen in #5 above), the stylesheet you enter in the Simplenews Template settings must of course reflect that particular HTML code.

You also asked if you "can refer to classes defined in my themes style.css in the body of the newsletter". You can't.

Tom Jacobs’s picture

in to #5 not work! code!

Parse error: syntax error, unexpected $end in /home/piramime/domains/piramime.ready4host.eu/public_html/sites/all/themes/bealestreet/template.php on line 716

Anonymous’s picture

Status: Fixed » Closed (fixed)

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

pelicani’s picture

You need to make sure that your php is aligned left, with no spaces or tabs, so the EOT can be properly read.

thomas74’s picture

Assigned: Unassigned » TBarregren
Status: Active » Closed (fixed)

Although this issue is et on closed I have the same issue. This is what happens in my case.
Gmail & Horde: e-mail is shown according template (see #5), CSS styles and inline styles (editor) are shown.
Hotmail & Outlook: e-mail is not shown according template (see #5), styles are not working, pictures are not shown, links are not displayed.

What is going wrong?

jboeger’s picture

I can't get the styles to show up in emails (gmail) either. Using latest of everything on 5.7

TBarregren’s picture

@thomas74 and @jboeger:

HTML-email is very difficult to get working across different e-mail clients. It requires carefully crafted HTML, judiciously use of CSS and testing, testing and more testing. This is beyond the scope of the module, which purpose is merely to provide mean to theme the Simplenews e-mails.

For your convenience, however, the module is shipped with a default mail theme based on the MailChimp templates. If you don't like the default template, you can easily replace it by your own. Start by crafting a single HTML-mail that works as you want on all clients you need to support. Test, test and test again. Not until it works as expected you may turn it into a theme.

See my links at Magnolia for more information on HTML-mail.

Mike Sances’s picture

Apparently gmail and other webmail strip out all css. See this post http://drupal.org/node/145676

Gmail in particular does not allow any [style] tags, according to this article: http://www.xavierfrenette.com/articles/css-support-in-webmail/

So, whether simplenews includes the style code in the body or head is irrelevant, at least for gmail.

This comment (http://drupal.org/node/145676#comment-815385) brings up a possible CSS + HTML -> HTML parser. Perhaps this could be accomplished with php or with a relatedcontent.tpl.php file.

mtpultz’s picture

Title: CSS not working » Template not showing up so don't have CSS either
Version: 5.x-1.0 » 6.x-1.0-beta3

Hi, I've got the lastest of both simplenews and simplenews template. But I can't get any changes to happen. I've changed the function in template.php of my admin and user themes (first one then the other as it didn't work). I've included the simplenews template and mail.css file in my admin folder, it used to show up in the email but doesn't anymore. Any suggestions?

I'm having a lot of problems getting simplenews themed. Was trying to have two column layout but with my own custom template but it isn't working.

Need to change the theming of the newsletter by adding some new template variables as well. How do you override this function so I can add or try too and change the variables available by themeing my own content.

/**
 * Process variables to format the simplenews newsletter body.
 *
 * $variables contains:
 * - $node
 * - $language
 *
 * @see simplenews-newsletter-body.tpl.php
 */
function template_preprocess_simplenews_newsletter_body(&$variables) {
  $variables['title'] = check_plain($variables['node']->title);
  $variables['body'] = $variables['node']->body;
}

I'd really appreciate the help as this contract is way over due completely due to not being able to get this newsletter to be themed properly.

andrenoronha’s picture

i'm trying to override the function at my template.php file but it's not working.
i have clened the cache but it doesnt seem to help...

is there any possiblity of giving css classes to the tags?

andrenoronha’s picture

i realized something now.

if the tag has a class it apply the css if you use only the class, like:

.image {
...
}

it does not apply css with hierarchy like:

.view .image {
...
}

andrenoronha’s picture

I'm overriding now the function
function theme_simplenews_template_content($newsletter_name, $issue_title, $header, $issue_body, $footer)

and it seems to work fine. i dont know when the other one is used. but it seems that this one makes the email body.