Re: [gentoo-user] Help with Script that sends out HTML emails

2005-09-20 Thread Nick Rout
On Sat, 2005-09-17 at 08:56 +0800, Ow Mun Heng wrote:
 mail -a Content-type: text/html; -s Your Daily Stock Quote
 [EMAIL PROTECTED]  filename.html 
 
 I have another problem now. for some reason, the system I was
 developing
 for (FC3), the mail command does not have a -a option. 
 
 I'm still searching for the correct mail 'version' in fc3. Anyone else
 has any more suggestions?

All I can say is that there are various packages that all
supply /bin/mail. In gentoo the package commonly used is
mail-client/mailx which hails from  debian.org (according to portage
$HOMEPAGE) but the source looks for like BSD, and the copyright is to
the Regents of the University of California, and the license is BSD.

mail-client/nail (nail.sf.net) will do the same job, and is described as
enhanced. It looks like it handles mime:

Supports the MIME specifications. Nail can send and receive attachments
and code and decode international character strings. If the system
libraries provide appropriate support, conversion between different
character encodings is performed. In combination with a UTF-8 terminal,
nearly all international languages are supported. External converter
programs can be automatically invoked e. g. to view messages in HTML
format.


I would look for a nail package for FC. 

-- 
gentoo-user@gentoo.org mailing list



Re: [gentoo-user] Help with Script that sends out HTML emails[SOLVED-Agn]

2005-09-19 Thread Ow Mun Heng
On Sun, 2005-09-18 at 22:36 -0500, John Jolet wrote:
 On Sunday 18 September 2005 22:11, A. Khattri wrote:
  On Mon, 19 Sep 2005, Ow Mun Heng wrote:
   Be that as it may, I'm not Perl person (picked up the book, but haven't
   really progressed anywhere hehe).
  
   But.. when push comes to shove
 
  Im assuming there is probably a CPAN module that does most of this for you
  - this is why I think Perl might be a better way to go.
 
 
  --
 there is...MIME::Entity...used thusly (from a perl program I use to email pdf 
 files, but you pass the mim-type on the command line, so it can send any mime 
 type):
 my $top = MIME::Entity-build(Type  = multipart/mixed,
   From  = [EMAIL PROTECTED],
   Bcc   = $address,
   Subject   = Mills Messenger by 
 e-Mail);
 
 $top-attach( Path  = $file_to_send,
   Type  = $mime_type,
   Encoding  = base64);
 
 my $message = Attached is your Mills Messenger for this week.  Enjoy!;
 $top-attach(Data=$message);
 
 open MAIL, |/usr/sbin/sendmail.postfix -t -oi -oem or die Error on 
 mail 
 o
 pen is: $!\n;
 $top-print(\*MAIL);
 close MAIL;

I did it, didn't have to go through perl. Just added a mail_header() to
my script.
mail_header()
{
echo MIME-Version:1.0
echo From:[EMAIL PROTECTED]
echo To:$RECIPIENT
echo Subject:Quotes $DATE
echo Content-Type: text/html
echo
}

and then I added a script for cron 
#!/bin/sh
#
TEMPFILE=/tmp/file.$$
PORTFOLIO_SCRIPT=$HOME/scripts/portfolio.sh

$PORTFOLIO_SCRIPT --html  $TEMPFILE 2/dev/null1
 /usr/sbin/sendmail -t  $TEMPFILE  rm $TEMPFILE

Next, I think the above code can be enhanced by not using a tempfile.
perhaps a  EOF 



-- 
Ow Mun Heng
Gentoo/Linux on DELL D600 1.4Ghz 1.5GB RAM
98% Microsoft(tm) Free!! 
Neuromancer 09:46:43 up 1 day, 4 min, 7 users, load average: 2.75, 2.30,
2.24 


-- 
gentoo-user@gentoo.org mailing list



Re: [gentoo-user] Help with Script that sends out HTML emails[SOLVED-Agn]

2005-09-19 Thread A. Khattri
On Tue, 20 Sep 2005, Ow Mun Heng wrote:

 I did it, didn't have to go through perl. Just added a mail_header() to
 my script.
 mail_header()
 {
 echo MIME-Version:1.0
 echo From:[EMAIL PROTECTED]
 echo To:$RECIPIENT
 echo Subject:Quotes $DATE
 echo Content-Type: text/html
 echo
 }

 and then I added a script for cron
 #!/bin/sh
 #
 TEMPFILE=/tmp/file.$$
 PORTFOLIO_SCRIPT=$HOME/scripts/portfolio.sh

 $PORTFOLIO_SCRIPT --html  $TEMPFILE 2/dev/null1
  /usr/sbin/sendmail -t  $TEMPFILE  rm $TEMPFILE

 Next, I think the above code can be enhanced by not using a tempfile.
 perhaps a  EOF


You could probably use a HERE document.

http://www.tldp.org/LDP/abs/html/here-docs.html

-- 

-- 
gentoo-user@gentoo.org mailing list



Re: [gentoo-user] Help with Script that sends out HTML emails[SOLVED-Agn]

2005-09-19 Thread Ow Mun Heng
On Tue, 2005-09-20 at 01:23 -0400, A. Khattri wrote:
 On Tue, 20 Sep 2005, Ow Mun Heng wrote:
 
  I did it, didn't have to go through perl. Just added a mail_header() to
  my script.

  #!/bin/sh
  #
  TEMPFILE=/tmp/file.$$
  PORTFOLIO_SCRIPT=$HOME/scripts/portfolio.sh
 
  $PORTFOLIO_SCRIPT --html  $TEMPFILE 2/dev/null1
   /usr/sbin/sendmail -t  $TEMPFILE  rm $TEMPFILE
 
  Next, I think the above code can be enhanced by not using a tempfile.
  perhaps a  EOF
 
 
 You could probably use a HERE document.
 
 http://www.tldp.org/LDP/abs/html/here-docs.html

Not sure what that is. No I-Net access currently.

Anyway, on the gentoo box, a simple 

$PORTFOLIO_SCRIPT --html 2/dev/null1 | /usr/sbin/sendmail -t

works. In Fedora, the system which will be sending it out, well, I
remember doing just that but it didn't work. Will try again.

-- 
gentoo-user@gentoo.org mailing list



Re: [gentoo-user] Help with Script that sends out HTML emails

2005-09-18 Thread Ow Mun Heng
On Sat, 2005-09-17 at 01:15 -0400, A. Khattri wrote:
 On Sat, 17 Sep 2005, Ow Mun Heng wrote:
 
  I have another problem now. for some reason, the system I was developing
  for (FC3), the mail command does not have a -a option.
 
  I'm still searching for the correct mail 'version' in fc3. Anyone else
  has any more suggestions?
 
 Unless you're prepared to use raw sendmail and generate all the headers
 yourself, you might be better off using perl and a module specifically
 designed to encode mail attachments correctly.

Sigh.. Yeah.. I can do this. It just involves using the -t to sendmail.

 
 Speaking as a programmer, perl is a lot easier to deal with than bash for
 textual operations such as this.

Be that as it may, I'm not Perl person (picked up the book, but haven't
really progressed anywhere hehe).

But.. when push comes to shove
 
 -- 
 

-- 
Ow Mun Heng
Gentoo/Linux on DELL D600 1.4Ghz 1.5GB RAM
98% Microsoft(tm) Free!! 
Neuromancer 10:28:00 up 45 min, 6 users, load average: 0.21, 0.50, 0.78 


-- 
gentoo-user@gentoo.org mailing list



Re: [gentoo-user] Help with Script that sends out HTML emails

2005-09-18 Thread A. Khattri
On Mon, 19 Sep 2005, Ow Mun Heng wrote:

 Be that as it may, I'm not Perl person (picked up the book, but haven't
 really progressed anywhere hehe).

 But.. when push comes to shove

Im assuming there is probably a CPAN module that does most of this for you
- this is why I think Perl might be a better way to go.


-- 

-- 
gentoo-user@gentoo.org mailing list



Re: [gentoo-user] Help with Script that sends out HTML emails

2005-09-18 Thread John Jolet

On Sunday 18 September 2005 22:11, A. Khattri wrote:
 On Mon, 19 Sep 2005, Ow Mun Heng wrote:
  Be that as it may, I'm not Perl person (picked up the book, but haven't
  really progressed anywhere hehe).
 
  But.. when push comes to shove

 Im assuming there is probably a CPAN module that does most of this for you
 - this is why I think Perl might be a better way to go.


 --
there is...MIME::Entity...used thusly (from a perl program I use to email pdf 
files, but you pass the mim-type on the command line, so it can send any mime 
type):
my $top = MIME::Entity-build(Type  = multipart/mixed,
  From  = [EMAIL PROTECTED],
  Bcc   = $address,
  Subject   = Mills Messenger by 
e-Mail);

$top-attach( Path  = $file_to_send,
  Type  = $mime_type,
  Encoding  = base64);

my $message = Attached is your Mills Messenger for this week.  Enjoy!;
$top-attach(Data=$message);

open MAIL, |/usr/sbin/sendmail.postfix -t -oi -oem or die Error on mail 
o
pen is: $!\n;
$top-print(\*MAIL);
close MAIL;

-- 
John Jolet
Your On-Demand IT Department
512-762-0729
www.jolet.net
[EMAIL PROTECTED]
-- 
gentoo-user@gentoo.org mailing list



Re: [gentoo-user] Help with Script that sends out HTML emails

2005-09-16 Thread Ow Mun Heng
On Thu, 2005-09-15 at 20:47 -0400, Willie Wong wrote:
 On Fri, Sep 16, 2005 at 07:07:23AM +0800, Ow Mun Heng wrote:
  Hi,
  
  I'm writing a bash script that basically checks for stocks prices and I
  want the formatted output to be mailed to me. I've got the script
  working already. The only problem is the HTML is well, not displayed as
  HTML, it's displayed RAW(and not formatted).
  
  I'm using cron to send the email out.
  
 
 Try using the mail command 
 
 behold the power of google:
 
   http://www.debian-administration.org/articles/171
 
 to put it simply: 
 
mail -a Content-type: text/html; -s Your Daily Stock Quote [EMAIL 
 PROTECTED]  filename.html 

I have another problem now. for some reason, the system I was developing
for (FC3), the mail command does not have a -a option. 

I'm still searching for the correct mail 'version' in fc3. Anyone else
has any more suggestions?

 Sortir en Pantoufles: up 35 days,  3:49

-- 
Ow Mun Heng
Gentoo/Linux on DELL D600 1.4Ghz 1.5GB RAM
98% Microsoft(tm) Free!! 
Neuromancer 08:56:21 up 12:56, 7 users, load average: 0.27, 0.37, 0.36 


-- 
gentoo-user@gentoo.org mailing list



Re: [gentoo-user] Help with Script that sends out HTML emails

2005-09-16 Thread A. Khattri
On Sat, 17 Sep 2005, Ow Mun Heng wrote:

 I have another problem now. for some reason, the system I was developing
 for (FC3), the mail command does not have a -a option.

 I'm still searching for the correct mail 'version' in fc3. Anyone else
 has any more suggestions?

Unless you're prepared to use raw sendmail and generate all the headers
yourself, you might be better off using perl and a module specifically
designed to encode mail attachments correctly.

Speaking as a programmer, perl is a lot easier to deal with than bash for
textual operations such as this.


-- 

-- 
gentoo-user@gentoo.org mailing list



Re: [gentoo-user] Help with Script that sends out HTML emails

2005-09-15 Thread Mike Williams
On Friday 16 September 2005 00:07, Ow Mun Heng wrote:
 I'm writing a bash script that basically checks for stocks prices
 and I want the formatted output to be mailed to me. I've got the script
 working already. The only problem is the HTML is well, not displayed as
 HTML, it's displayed RAW(and not formatted).

 I'm using cron to send the email out.

I don't think it'll ever work. The problem is you need to add the content type 
to the headers.
Mutt has an option to specify a draft file to read header and body from, but 
seems to lose/re-write the content-type.

-- 
Mike Williams

-- 
gentoo-user@gentoo.org mailing list



Re: [gentoo-user] Help with Script that sends out HTML emails

2005-09-15 Thread Nick Rout
It seems to me that you need a couple of other things:

1. a look at a couple of the html emails in my inbox show a mail
header (ie part of the email where stuff like from, to and subject go) like 
this:

MIME-Version: 1.0
Content-Type: multipart/alternative;
boundary=_=_NextPart_001_01C5B8D9.821B04F0

you can add extra headers using the mail command with the -a parameter 
(according to man mail)

 -a  Specify additional header fields on the command line such as X-Loop: 
[EMAIL PROTECTED] etc.  You have to use
 quotes if the string contains spaces.  This argument may be 
specified more than once, the headers
 will then be concatenated.

2. The body of the message must be in mime format using the same boundary as 
is specified in the header like this:

--_=_NextPart_001_01C5B8D9.821B04F0
Content-Type: text/plain
(here is the text part of the message)

--_=_NextPart_001_01C5B8D9.821B04F0
Content-Type: text/html
Content-Transfer-Encoding: quoted-printable

!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 3.2//EN
HTML (all the html bits)
/HTML

below that the boundary is specified again:

--_=_NextPart_001_01C5B8D9.821B04F0--

(thats the very last line in the file)


3. i tried using mpack to make an html message from the command line,
but it didn't work - I might be doing something wrong.


On Fri, 16 Sep 2005 07:07:23 +0800
Ow Mun Heng wrote:

 Hi,
 
   I'm writing a bash script that basically checks for stocks prices and I
 want the formatted output to be mailed to me. I've got the script
 working already. The only problem is the HTML is well, not displayed as
 HTML, it's displayed RAW(and not formatted).
 
 I'm using cron to send the email out.
 
 I've even put the echo statement :
 
 html_header()
 {
 echo Content-Type: text/html; charset=iso-8859-1
 echo HTMLHEADTITLEStock Quotes : $DATE /TITLE/HEAD
 echo 'STYLE TYPE=TEXT/CSS'
 echo h1 {color: gray; border-bottom: 3px double silver}
 echo h2,h3 {color: gray; border-bottom: 1px solid silver}
 echo /STYLE/HEAD
 echo BODY
 echo H1Stock Quotes : $DATE /H1
 echo BRBR
 }
 
 
 but all I get is :
 
 Content-Type: text/html; charset=iso-8859-1
 HTMLHEADTITLEStock Quotes : Fri Sep 16 06:52:02 2005
 /TITLE/HEAD
 STYLE TYPE=TEXT/CSS
 h1 {color: gray; border-bottom: 3px double silver}
 h2,h3 {color: gray; border-bottom: 1px solid silver}
 /STYLE/HEAD
 BODY
 H1Stock Quotes : Fri Sep 16 06:52:02 2005 /H1
 BRBR
 
 What sort of content-type do I need to put into it? or do I have to
 format the message and use sendmail -t  quote
 
 
 -- 
 Ow Mun Heng
 Gentoo/Linux on DELL D600 1.4Ghz 1.5GB RAM
 98% Microsoft(tm) Free!! 
 Neuromancer 07:03:30 up 2 days, 19:38, 6 users, load average: 0.80,
 0.49, 0.52 
 
 
 -- 
 gentoo-user@gentoo.org mailing list

-- 
Nick Rout [EMAIL PROTECTED]

-- 
gentoo-user@gentoo.org mailing list



Re: [gentoo-user] Help with Script that sends out HTML emails

2005-09-15 Thread Willie Wong
On Fri, Sep 16, 2005 at 07:07:23AM +0800, Ow Mun Heng wrote:
 Hi,
 
   I'm writing a bash script that basically checks for stocks prices and I
 want the formatted output to be mailed to me. I've got the script
 working already. The only problem is the HTML is well, not displayed as
 HTML, it's displayed RAW(and not formatted).
 
 I'm using cron to send the email out.
 

Try using the mail command 

behold the power of google:

  http://www.debian-administration.org/articles/171

to put it simply: 

   mail -a Content-type: text/html; -s Your Daily Stock Quote [EMAIL 
PROTECTED]  filename.html 

HTH

W
-- 
I know that there are people in this world
who do not love their fellow man,
and I HATE people like that.   -- Tom Lehrer
Sortir en Pantoufles: up 35 days,  3:49
-- 
gentoo-user@gentoo.org mailing list



Re: [gentoo-user] Help with Script that sends out HTML emails [SOLVED]

2005-09-15 Thread Ow Mun Heng
On Thu, 2005-09-15 at 20:47 -0400, Willie Wong wrote:
 On Fri, Sep 16, 2005 at 07:07:23AM +0800, Ow Mun Heng wrote:
  Hi,
  
  I'm writing a bash script that basically checks for stocks prices and I
  want the formatted output to be mailed to me. I've got the script
  working already. The only problem is the HTML is well, not displayed as
  HTML, it's displayed RAW(and not formatted).
  
  I'm using cron to send the email out.
  
 
 Try using the mail command 
 
 behold the power of google:

I did, but obviously searching for bash script + email + HTML + format
doesn't yield anything since it can't be done(?)

 
   http://www.debian-administration.org/articles/171
 
 to put it simply: 
 
mail -a Content-type: text/html; -s Your Daily Stock Quote [EMAIL 
 PROTECTED]  filename.html 

I tried that. It worked perfectly. Only thing now, I'll have to hack the
script to put the output into a file and send our the file instead of
using cron.

Should be a simple thing.

Thanks.

 
 HTH
 
 W
 -- 
 I know that there are people in this world
 who do not love their fellow man,
 and I HATE people like that.   -- Tom Lehrer
 Sortir en Pantoufles: up 35 days,  3:49

-- 
Ow Mun Heng
Gentoo/Linux on DELL D600 1.4Ghz 1.5GB RAM
98% Microsoft(tm) Free!! 
Neuromancer 09:14:16 up 2 days, 21:48, 7 users, load average: 1.55,
1.10, 2.36 


-- 
gentoo-user@gentoo.org mailing list



Re: [gentoo-user] Help with Script that sends out HTML emails [SOLVED]

2005-09-15 Thread John Jolet


On Sep 15, 2005, at 8:14 PM, Ow Mun Heng wrote:


On Thu, 2005-09-15 at 20:47 -0400, Willie Wong wrote:


On Fri, Sep 16, 2005 at 07:07:23AM +0800, Ow Mun Heng wrote:


Hi,

I'm writing a bash script that basically checks for stocks  
prices and I

want the formatted output to be mailed to me. I've got the script
working already. The only problem is the HTML is well, not  
displayed as

HTML, it's displayed RAW(and not formatted).

I'm using cron to send the email out.




Try using the mail command

behold the power of google:



I did, but obviously searching for bash script + email + HTML +  
format

doesn't yield anything since it can't be done(?)




  http://www.debian-administration.org/articles/171

to put it simply:

   mail -a Content-type: text/html; -s Your Daily Stock Quote  
[EMAIL PROTECTED]  filename.html




I tried that. It worked perfectly. Only thing now, I'll have to  
hack the

script to put the output into a file and send our the file instead of
using cron.

Should be a simple thing.

Thanks.




HTH

W
--
I know that there are people in this world
who do not love their fellow man,
and I HATE people like that.   -- Tom Lehrer
Sortir en Pantoufles: up 35 days,  3:49



--
Ow Mun Heng
Gentoo/Linux on DELL D600 1.4Ghz 1.5GB RAM
98% Microsoft(tm) Free!!
Neuromancer 09:14:16 up 2 days, 21:48, 7 users, load average: 1.55,
1.10, 2.36


--
gentoo-user@gentoo.org mailing list




you could also write a small perl script to actually send the  
emailI send out a newsletter that way every week.

--
gentoo-user@gentoo.org mailing list



Re: [gentoo-user] Help with Script that sends out HTML emails [SOLVED]

2005-09-15 Thread Ow Mun Heng
On Thu, 2005-09-15 at 20:30 -0500, John Jolet wrote:
 On Sep 15, 2005, at 8:14 PM, Ow Mun Heng wrote:
 
  On Thu, 2005-09-15 at 20:47 -0400, Willie Wong wrote:
 
  On Fri, Sep 16, 2005 at 07:07:23AM +0800, Ow Mun Heng wrote:
 
  Hi,
 
  I'm writing a bash script that basically checks for stocks  
  prices and I
  want the formatted output to be mailed to me. I've got the script
  working already. The only problem is the HTML is well, not  
  displayed as
  HTML, it's displayed RAW(and not formatted).
 
  I'm using cron to send the email out.
 
  Try using the mail command
http://www.debian-administration.org/articles/171
 
  to put it simply:
 
 mail -a Content-type: text/html; -s Your Daily Stock Quote  
  [EMAIL PROTECTED]  filename.html
 
 
  I tried that. It worked perfectly. Only thing now, I'll have to  
  hack the
  script to put the output into a file and send our the file instead of
  using cron.
 
  Should be a simple thing.
 
 
 
 you could also write a small perl script to actually send the  
 emailI send out a newsletter that way every week.

That's what I just did..
$ cat cron_fetch_stock.sh 
#!/bin/bash
#
TEMPFILE=/tmp/file.$$
PORTFOLIO_SCRIPT=$HOME/scripts/portfolio.sh

$PORTFOLIO_SCRIPT --html  $TEMPFILE 2/dev/null1  mail -a
Content-Type: text/html -s Stock Quotes `date +%c`  $TEMPFILE
gentoo  rm $TEMPFILE



-- 
Ow Mun Heng
Gentoo/Linux on DELL D600 1.4Ghz 1.5GB RAM
98% Microsoft(tm) Free!! 
Neuromancer 09:42:48 up 2 days, 22:17, 7 users, load average: 1.06,
0.86, 1.06 


-- 
gentoo-user@gentoo.org mailing list



Re: [gentoo-user] Help with Script that sends out HTML emails [SOLVED]

2005-09-15 Thread Nick Rout

On Fri, 16 Sep 2005 09:43:50 +0800
Ow Mun Heng wrote:

 That's what I just did..
 $ cat cron_fetch_stock.sh 
 #!/bin/bash
 #
 TEMPFILE=/tmp/file.$$
 PORTFOLIO_SCRIPT=$HOME/scripts/portfolio.sh
 
 $PORTFOLIO_SCRIPT --html  $TEMPFILE 2/dev/null1  mail -a
 Content-Type: text/html -s Stock Quotes `date +%c`  $TEMPFILE
 gentoo  rm $TEMPFILE


whats wrong with :

$PORTFOLIO_SCRIPT --html 2/dev/null | mail -a  Content-Type: text/html -s 
Stock Quotes `date +%c`

Assuming $PORTFOLIO_SCRIPT outputs to stdout (it should).

-- 
Nick Rout [EMAIL PROTECTED]

-- 
gentoo-user@gentoo.org mailing list