Re: [gentoo-user] Help with Script that sends out HTML emails[SOLVED-Agn]
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/null>&1 > > && /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/null>&1 | /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[SOLVED-Agn]
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/null>&1 > && /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]
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/null>&1 && /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]
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/null>&1 && 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
Re: [gentoo-user] Help with Script that sends out HTML emails [SOLVED]
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/null>&1 && 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]
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]
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