LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-21-2011, 02:01 AM   #1
kdelover
Member
 
Registered: Aug 2009
Posts: 311

Rep: Reputation: 36
perl sendmail with CSS


Hi,
I need to send email through perl using CSS.Eventhough the mail is sent,all i see in my thunderbird is html code.

Css file:
Code:
table.pretty {
  margin: 1em 1em 1em 2em;
  background: whitesmoke;
  border-collapse: collapse;
}
table.pretty th, table.pretty td {
  border: 1px silver solid;
  padding: 0.2em;
}
table.pretty th {
  background: gainsboro;
  text-align: left;
}
table.pretty caption {
  margin-left: inherit;
  margin-right: inherit;
}
Script:

Code:
#!/usr/bin/perl
use strict;
use warnings;
use MIME::Lite;
my $text2=<<CSS;
<html><body>
<LINK REL=StyleSheet HREF="pretty.css" TITLE="Contemporary">
<table class="pretty.css">
<tr>
<th>Key</th><th>Value</th>
</tr>
<tr>
<td>ACT</td><td>Australian Capital Territory</td>
</tr>
<tr>
<td>NSW</td><td>New South Wales</td>
</tr>
<tr>
<td>NT</td><td>Northern Territory</td>
</tr>
<tr>
<td>QLD</td><td>Queensland</td>
</tr>
<tr>
<td>SA</td><td>South Australia</td>
</tr>
<tr>
<td>TAS</td><td>Tasmania</td>
</tr>
<tr>
<td>VIC</td><td>Victoria</td>
</tr>
<tr>
<td>WA</td><td>Western Australia</td>
</tr>
</table>
</body>
</html>
CSS

my $msg = MIME::Lite->new(
From    => 'user@id.com',
To      => 'user@id.com',
Subject => "test",
Type    => "text/css",
Encoding => 'base64',
Data    => "$text2"
);

$msg->attach(Type=> 'multipart/mixed',
             Path =>'/home/user/pretty.css',
             Filename =>'pretty.css',);

$msg->send;
This works but with out stylesheets if i use text/html,and i see html code if iuse text/css.Thanks
 
Old 03-21-2011, 02:46 AM   #2
kdelover
Member
 
Registered: Aug 2009
Posts: 311

Original Poster
Rep: Reputation: 36
Ok got it,

Using inline css fixed it.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
CSS - Is there a way to put several lines of HTML into one line using CSS? Chronothread Programming 12 01-05-2011 06:06 AM
Perl& Css maas187 Linux - Software 4 10-05-2008 09:09 PM
HTML/CSS/JS: Problem with <p> not having an absolute position with CSS. RHLinuxGUY Programming 7 03-03-2007 12:21 AM
Perl Sendmail problem sasklinuxuser Programming 2 05-28-2005 11:51 AM
perl/sendmail/mailfilter help requested joesbox Programming 1 03-04-2003 11:07 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:31 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration