Welcome to the Linux Foundation Forum!
auto print email attachments as they arrive
kevinclancy
Posts: 7
in Applications
auto print email attachments as they arrive
why is this so hard to find information on? I used a windows program in my windows computer it worked great untill the 30 days was up
I have tried "Claws mail" it seems to have actions and commands but I am way to nuibie to get how it can be done
I am open to any suggestions
the reason I want this is going to be handy to many and I tell you why - I have a Voip phone and receive all my incoming faxes to my Email as a pdf attachment. I cant be checking my email ever 5 minutes its just impractical.
any help or ideas?
0
Comments
-
Shouldn't be that hard with a little scrip. I'm no expert though
Maybe someone else can make a little script to send the attachments to your printer (although for that I guess we'll need more information about your system...)0 -
Gmail, for example, can filter emails with just the "has an attachment" option checked. A cron job that prints everything in a certain folder can print the filtered emails after they're vectored to that folder. I find it inherently dangerous to print out all attachments, but, it all depends on how your filters work. It may be easier than you think.0
-
I have been using linux mint - I have an email address that only gets messages sent by my Faxmail so every email has a PDF attachment - how do I make a cron job?0
-
I do not have any guidance to offer, but the like the idea of this task. I have forwarded info about this request to a knowledgeable group I know and hopefully someone will come offer guidance.0
-
My inquiry to outside users has yielded responses and confirmation that it has been done. I am currently awaiting a confirmation from the responders that I can repost their responses.0
-
Here are the responses I received so far, I don't think these people want to join a forum, but they agreed to allow me to repost their information.
James
At one time I had a php script that automatically printed any emails sent to z special address. It would actually be easy to adapt it to attachments. I'll look through my backups and see if I can change it. If I did maybe someone could concert.
Henry
The guy wants his email PDF attachments automatically printed. I do similar
things at work.
1. Set up procmail. I do this the old way, by creating a ~/.forward file
containing
"|exec /usr/bin/procmail"
2. Set up a procmail rule in ~/.procmailrc for his emails. It sounds like they
are all coming from one email address, so that would make it really easy. If
they are coming from multiple addresses, then you could still create a
procmail rule based on the To address (and using a special address to receive
the fax on), or specifying a specific subject line. Assuming one from address,
you would have a procmail rule like this:
:0
* ^From:.*myvoip@myvoipdomain.com
| "/home/myname/bin/handle_pdf_att"
3. Create program to process the emails - ~/bin/handle_pdf_att. At this point,
most people say "it's Linux, write your own". I wrote a Perl program that
accepts the emails via stdin, and processes them. Initially I used the Perl
email and MIME libraries from CPAN, but they really sucked, and when I needed
some more detailed mail handling, I found too many of them said things like
"not implemented yet" or "author stopped here and then disappeared, someone
needs to finish this stuff". I wrote my own Perl module to parse the emails,
extract attachments, decode them, etc. Very direct, not fancy, did precisely
what I needed and no more. Not worth passing back to CPAN, not generic enough.
But good enough to handle all incoming email for several domains for several
years without needing attention. If your user wanted, I could easily produce a
new Perl program to extract PDFs from the emails, decode them, write them to
disk so he has permanent storage of them, and then print them. It would take a
few hours. I would be happy to do this.
Henry
Henry wrote:
> 1. Set up procmail. I do this the old way, by creating a ~/.forward file
> 2. Set up a procmail rule in ~/.procmailrc for his emails. It sounds like they
> 3. Create program to process the emails - ~/bin/handle_pdf_att. At this point,
This would only work if the user was using a traditional email system on his
Linux box. One where there is an MTA on the box (sendmail, postfix, qmail,
etc) and his MUA (pine, mutt, etc) pulled from it. And fetchmail pulled from
the ISP and handed email to the MTA. I think that is not common today.
If they have an MUA like Thunderbird that pulls directly from an ISP,
eliminating the need for having an MTA on the box, then my suggested approach
will not work. And I think that this is the more usual way that Linux boxes
are set up these days.
I will post additional responses as they arrive or relay additional questions that you have for the responders.0 -
thanks for the input -
I was wondering , this claws email has actions and commands that can be added in the gui, but I dont understand how that all works.
anyway any suggestions will be tried and tested to the best of my abilities
Cheers0 -
Must it be with claws email or can you use another mail client?0
-
No anything that will work will be great - http://www.linux.com/components/com_kunena/template/default/images/english/emoticons/smile.png
the ultimate solution is a set-up would be
1. email is checked every say 2 minutes
2. emails that have just arrived get downloaded
2. emails with an attachment get there attachment printed forthwith
It would be best if this worked in the background and ran 24 / 7 and restarted its self even if the computer restarted0 -
Hi,
I see this post was inactive for some time and I hope my answer will still help.
I just set up exactly what you are trying to do.
Programs needed:
[ul][li]fetchmail[/li][li]uudeview[/li][li]cups[/li][/ul]
I created a user named "autoprint" for this task
First you need to set up fetchmail to retrieve mail from your account and save it to a file.
In the users home directory create file .fetchmailrc and do chmod 600 on it (fetchmail will issue a warning if other users have read privileges on this file)
it should have following content:poll your.mailserver.xx proto POP3 user your-mailbox-username pass secretpassword
for proto you should also be able to use IMAP.
now you just need a shell script to download mail and print it:#!/bin/bash SUPPORTED_FILETYPES=.pdf.jpg LP_OPTIONS=-o media=A4,tray1 -o fit-to-page -o position=top -o scaling=100 FILENAME=$(date +%H%M%S).txt /usr/bin/fetchmail --bsmtp ~/mailtemp/$FILENAME if [ "$?" = "0" ]; then /usr/bin/uudeview +e $SUPPORTED_FILETYPES -p ~/printable -i ~/mailtemp/$FILENAME rm ~/mailtemp/$FILENAME for f in ~/printable/* do lp $LP_OPTIONS $f rm $f done fi
The script does the following:
[ul][li]save the mail to a file naed by the current time - just in case two files exist at the same time which should not happen[/li][li]If mail has been retrieved, pass the file to uudeview and extract all attachments with the extensions listet in FILETYPES. Which files are supported by cups, you can find with google. uudeview also accepts multiple emails in one file[/li][li]The extracted files are then printed with lp using the options from LP_OPTIONS if the printer to be used is not your standard printer, you should add -d printername to the lp command [/li][li]the files are deleted after being processed. So is the mail, when fetchmail downloads it[/li][/ul]
When you have tested the script on the command line and it works, you have to make cron run this script every 2, 5 minutes or whatever you like.
With this solution, no filtering is done on the linux box. I set up the mail-account, to only accept mails from my address, to counter spam.
Sure this is not the most secure solution, but if nobody knows the mail-address and neither that there is a printer-deamon behind it, for myself I feel secure enough.
You could still expand the script to extract also a S/MIME signature attached to your mails and have that before printing.
Taraman0 -
Thanks a lot I appreciate the help I will give this a try and see how I go and will let ya know
Thanks0 -
I now added an eMail-Response in case of failure to print.
This needs a working mail command.#!/bin/bash SUPPORTED_FILETYPES=".pdf.jpg.png.tif.gif" LP_OPTIONS="-o media=A4,tray1 -o fit-to-page -o position=top -o scaling=100" MAILFILE=~/mailtemp/$(date +%H%M%S).txt PRINT_FOLDER=~/printable /usr/bin/fetchmail --bsmtp $MAILFILE if [ "$?" = "0" ]; then MAIL_ADDRESS=$(grep 'From:' $MAILFILE | sed -n -e 's/^[^<]*<\([^>]*\)>.*$/\1/p') /usr/bin/uudeview +e $SUPPORTED_FILETYPES -p $PRINT_FOLDER -i $MAILFILE rm $MAILFILE PRINTED="no" for f in $PRINT_FOLDER/* do if [ "$f" != "$PRINT_FOLDER/*" ]; then LP_OUTPUT=$(lp $LP_OPTIONS $f) if [ "$?" != "0" ]; then MAILTEXT="File $f could not be printed." echo "$MAILTEXT" | mail -s "Print-Error" $MAIL_ADDRESS fi rm $f PRINTED="yes" else if [ "$PRINTED" = "no" ]; then echo "No printable Attachments" | mail -s "Print-Error" $MAIL_ADDRESS fi fi done ~/mailprint fi
For that to work, you have to add the following line to your .fetchmailrc:fetchlimit 1
With this line, only one mail is received each time the script is executed.
Therefore the script calls itself again as long as messages are downloaded.0 -
Thanks a lot for your help - I have had an other problem unrelated to this one that would love to have solved dont know if its up your ally so to speak http://www.linux.com/community/forums?func=view&catid=22&id=9161
any ideas ?0 -
I fear, that is not my cup of tea...0
Categories
- All Categories
- 167 LFX Mentorship
- 219 LFX Mentorship: Linux Kernel
- 795 Linux Foundation IT Professional Programs
- 355 Cloud Engineer IT Professional Program
- 179 Advanced Cloud Engineer IT Professional Program
- 82 DevOps Engineer IT Professional Program
- 127 Cloud Native Developer IT Professional Program
- 112 Express Training Courses
- 112 Express Courses - Discussion Forum
- 6.2K Training Courses
- 48 LFC110 Class Forum - Discontinued
- 17 LFC131 Class Forum
- 35 LFD102 Class Forum
- 227 LFD103 Class Forum
- 14 LFD110 Class Forum
- 39 LFD121 Class Forum
- 15 LFD133 Class Forum
- 7 LFD134 Class Forum
- 17 LFD137 Class Forum
- 63 LFD201 Class Forum
- 3 LFD210 Class Forum
- 5 LFD210-CN Class Forum
- 2 LFD213 Class Forum - Discontinued
- 128 LFD232 Class Forum - Discontinued
- 1 LFD233 Class Forum
- 2 LFD237 Class Forum
- 23 LFD254 Class Forum
- 697 LFD259 Class Forum
- 109 LFD272 Class Forum
- 3 LFD272-JP クラス フォーラム
- 10 LFD273 Class Forum
- 152 LFS101 Class Forum
- 1 LFS111 Class Forum
- 1 LFS112 Class Forum
- 1 LFS116 Class Forum
- 1 LFS118 Class Forum
- LFS120 Class Forum
- 7 LFS142 Class Forum
- 7 LFS144 Class Forum
- 3 LFS145 Class Forum
- 1 LFS146 Class Forum
- 3 LFS147 Class Forum
- 1 LFS148 Class Forum
- 15 LFS151 Class Forum
- 1 LFS157 Class Forum
- 33 LFS158 Class Forum
- 8 LFS162 Class Forum
- 1 LFS166 Class Forum
- 1 LFS167 Class Forum
- 3 LFS170 Class Forum
- 2 LFS171 Class Forum
- 1 LFS178 Class Forum
- 1 LFS180 Class Forum
- 1 LFS182 Class Forum
- 1 LFS183 Class Forum
- 29 LFS200 Class Forum
- 736 LFS201 Class Forum - Discontinued
- 2 LFS201-JP クラス フォーラム
- 14 LFS203 Class Forum
- 102 LFS207 Class Forum
- 1 LFS207-DE-Klassenforum
- 1 LFS207-JP クラス フォーラム
- 301 LFS211 Class Forum
- 55 LFS216 Class Forum
- 48 LFS241 Class Forum
- 42 LFS242 Class Forum
- 37 LFS243 Class Forum
- 15 LFS244 Class Forum
- LFS245 Class Forum
- LFS246 Class Forum
- 50 LFS250 Class Forum
- 1 LFS250-JP クラス フォーラム
- LFS251 Class Forum
- 154 LFS253 Class Forum
- LFS254 Class Forum
- LFS255 Class Forum
- 5 LFS256 Class Forum
- 1 LFS257 Class Forum
- 1.3K LFS258 Class Forum
- 10 LFS258-JP クラス フォーラム
- 111 LFS260 Class Forum
- 159 LFS261 Class Forum
- 41 LFS262 Class Forum
- 82 LFS263 Class Forum - Discontinued
- 15 LFS264 Class Forum - Discontinued
- 11 LFS266 Class Forum - Discontinued
- 20 LFS267 Class Forum
- 24 LFS268 Class Forum
- 29 LFS269 Class Forum
- 1 LFS270 Class Forum
- 199 LFS272 Class Forum
- 1 LFS272-JP クラス フォーラム
- LFS274 Class Forum
- 3 LFS281 Class Forum
- 9 LFW111 Class Forum
- 260 LFW211 Class Forum
- 182 LFW212 Class Forum
- 13 SKF100 Class Forum
- 1 SKF200 Class Forum
- 1 SKF201 Class Forum
- 782 Hardware
- 198 Drivers
- 68 I/O Devices
- 37 Monitors
- 96 Multimedia
- 174 Networking
- 91 Printers & Scanners
- 83 Storage
- 743 Linux Distributions
- 80 Debian
- 67 Fedora
- 15 Linux Mint
- 13 Mageia
- 23 openSUSE
- 143 Red Hat Enterprise
- 31 Slackware
- 13 SUSE Enterprise
- 348 Ubuntu
- 461 Linux System Administration
- 39 Cloud Computing
- 70 Command Line/Scripting
- Github systems admin projects
- 90 Linux Security
- 77 Network Management
- 101 System Management
- 46 Web Management
- 64 Mobile Computing
- 17 Android
- 34 Development
- 1.2K New to Linux
- 1K Getting Started with Linux
- 371 Off Topic
- 114 Introductions
- 174 Small Talk
- 19 Study Material
- 507 Programming and Development
- 285 Kernel Development
- 204 Software Development
- 1.8K Software
- 211 Applications
- 180 Command Line
- 3 Compiling/Installing
- 405 Games
- 309 Installation
- 97 All In Program
- 97 All In Forum
Upcoming Training
-
August 20, 2018
Kubernetes Administration (LFS458)
-
August 20, 2018
Linux System Administration (LFS301)
-
August 27, 2018
Open Source Virtualization (LFS462)
-
August 27, 2018
Linux Kernel Debugging and Security (LFD440)