[GRLUG] Printing HTML emails from the command line

Jeff DeFouw jeffd at i2k.com
Fri Feb 15 00:31:15 EST 2008


On Thu, Feb 14, 2008 at 11:21:22PM -0500, Michael Mol wrote:
> My grandmother has an email account, but doesn't use the computer to
> check it. Instead, she wants me to.  I'd like to set up a cron script
> to automatically POP her email, and then print it out.
> 
> I'm not worried about spam.  It's a Gmail address, and she gets
> perhaps one or two junk emails a month.
> 
> I'm handy enough with Perl et al to handle mbox; It's having something
> that can render the emails without an X display that I'm worried
> about.

Everything I've seen that you might be able to get to work uses X.  
Could you use a virtual X server (Xvfb)?

There are several Firefox extensions for automated printing, but not 
from the command line.  Maybe with a bit more code they could.  Or maybe 
you could control the window with a script.  You could also save the 
page to an image with the Screengrab extension, but there's no 
command-line interface.  There's a commercial extension that will save a 
web page to an image from a command line, but I don't see a built-in 
print function.

There's a program called khtml2png that uses KDE libs to convert web 
pages to images.  It doesn't need to show a window but it probably still 
needs X.  You might be able to print the resulting images.

Also in KDE land, Konqueror can be easily controlled remotely.  Here's a 
thread that describes printing a page:
http://www.nabble.com/Automating-firefox-td14785985.html
(Scroll to the bottom of the page.)

-- 
Jeff DeFouw <jeffd at i2k.com>


More information about the grlug mailing list