Linux.com

Author Message
Joined: Jun 06, 2008
Posts: 1
Other Topics
Posted Jun 06, 2008 at 6:55:42 PM
Subject: AUTOMATIC EMAIL PRINTING
I need to automatically print every email message I get from a GMAIL, YAHOO or HOTMAIL account, the process must be unattended. Is there an application like this? It can be a client application that checks for incomming messages and automatically prints them with some kind of filtering.
Back to top Profile Email Website
Khabi
Joined Apr 21, 2008
Posts: 121

Other Topics
Posted: Jun 06, 2008 9:13:40 PM
Subject: AUTOMATIC EMAIL PRINTING
I don't think you're going to find an application specifically fro this. But I can at least get you pointed in the right direction with some normal command line applications. This is going to require some work on your part however. You can break the process down to 3 parts. -Checking the email (application named fetchmail) -Filter the emails to see if you want them printed (application named procmail) -Printing the email - command line printing via cups (application named lp *I think*) All of these applications run from the command line and you could write a small bash script to put them all together and run it from cron every 10-15 minutes (or however often you need it to run). A good quickstart for fetchmail + procmail: http://www.ilkertemir.com/document/fetchmail-procmail.html You should be able to google 'command line linux printing" to figure out how to print a file from the command line. My guess on a good flow would be something like: run fetchmail to get all new emails -> filter those emails thru procmail and any emails you want printed have saved to a specific directory (something like /var/spool/printmail or something) -> loop thru all the emails in that directory and print them, deleting each email as they're done printing. Its a bit of work, but its by no means impossible. I have no problems helping you with logic questions, but I'm not going to write it for ya. ;) Or you could get lucky and maybe someone will suggest a full featured app to do all of this already. :) [Modified by: Khabi on June 06, 2008 09:14 PM]
Back to top Profile Email Website
Jason Ellison
Joined Oct 01, 2008
Posts: 1

Other Topics
Posted: Oct 01, 2008 11:29:06 PM
Subject: AUTOMATIC EMAIL PRINTING
Email to Printer Gateway Jason Ellison infotek@gmail.com http://www.jasonellison.net/ This document covers setting up a Linux box to download email from a POP3 account on a Microsoft Exchange server and printing it to a network printer. When the emails are downloaded they are deleted. Already read emails are also deleted. Only new emails will be printed. This example was done using Slackware 12.0.0 Setup printer in cups chmod 755 /etc/rc.d/rc.cups /etc/rc.d/rc.cups start links http://127.0.0.1:631/ add the printer, print a test page, and make it the default or specify it in the lpr command. Create user root@monitor:~# adduser Login name for new user []: printemail User ID ('UID') [ defaults to next available ]: Initial group [ users ]: Additional groups (comma separated) []: Home directory [ /home/printemail ] Shell [ /bin/bash ] /bin/false - Warning: /bin/false is not in /etc/shells (potential problem using FTP) Do you wish to change the shell ? (Y/n) n Expiry date (YYYY-MM-DD) []: New account will be created as follows: --------------------------------------- Login name.......: printemail UID..............: [ Next available ] Initial group....: users Additional groups: [ None ] Home directory...: /home/printemail Shell............: /bin/false Expiry date......: [ Never ] This is it... if you want to bail out, hit Control-C. Otherwise, press ENTER to go ahead and make the account. Creating new account... Changing the user information for printemail Enter the new value, or press ENTER for the default Full Name []: Room Number []: Work Phone []: Home Phone []: Other []: Changing password for printemail Enter the new password (minimum of 5, maximum of 127 characters) Please use a combination of upper and lower case letters and numbers. New password: Bad password: too short. Warning: weak password (enter it again to use it anyway). New password: Re-enter new password: Password changed. Account setup complete. root@monitor:~# usermod -p a5wEg324s printemail root@monitor:~# usermod -L printemail I disable the account from remote logins for security. Slackware's cron daemon does not use the users shell anyway. Configure Fetchmail to retrieve email into the local account Use fetchmail to obtain mail from remote locations. printemail@monitor:~$ cat .fetchmailrc poll mail.example.org with proto POP3 and options no dns user 'support' there with password 's3cr3t' is 'printemail' here and wants mda "/usr/bin/procmail -d %T" options nokeep flush printemail@monitor:~$ chmod 0710 .fetchmailrc Script mailx to print email Create a mailx command file that: a. prints the first email b. deletes the first email c. quits the program * note: I tried to do this using mailrc but the program would not respect the quit command when there were more than 2 emails in the mailbox !*? #.mailcmd set cmd=/usr/bin/lpr set page=yes set pipe-text/html="lynx -dump -force_html /dev/stdin" #mailrc would not respect the quit command folder /var/mail/printemail pipe 1 /usr/bin/lpr delete 1 quit Then write a bash script to run mailx until no new mail exists in the mailbox. #!/usr/bin/bash #/usr/local/bin/print_email.sh #fetch the new mail /usr/bin/fetchmail > /dev/null #print all new mail while ( /usr/bin/mailx -e > /dev/null 2>&1 ); do /usr/bin/mailx -B < ~/.mailcmd ; sleep 1 ; done Schedule the job Finally you would want to cron the job so that it runs every five minutes. root@nebula:~# crontab -l | grep print_email # print_email every five minutes */5 * * * * /usr/local/bin/print_email.sh 1> /dev/null http://jasonellison.net/files/Email_to_printer_gateway.pdf
Back to top Profile Email Website
Tableless layout Validate XHTML 1.0 Strict Validate CSS Powered by Xaraya