Email inbox to printer

A

Aki

Hi,

I am currently using fetchmail to retrieve mail from a POP server
every couple of minutes, and it is delivering it to the standard
/var/spool/mail/$user

I need a script to monitor this users new mail when fetchmail has
retrieved one, and make an audible alert to alert everyone of its
arrival and also to print out the new email to the default printer.

Any ideas? All help would be greatly received, I am open to any
suggestions.

regards,

Aki.
 
B

Ben Morrow

Quoth (e-mail address removed) (Aki):
I am currently using fetchmail to retrieve mail from a POP server
every couple of minutes, and it is delivering it to the standard
/var/spool/mail/$user

I need a script to monitor this users new mail when fetchmail has
retrieved one, and make an audible alert to alert everyone of its
arrival and also to print out the new email to the default printer.

Fetchmail in its usual setup doesn't deliver to the user's mailbox
itself, but rather hands the mail off to the local MTA for delivery. If
this is the case, then it's probably easiest to arrange for this user's
mail to be forwarded to a script which does what you want with it. Some
setup like this should work (depending on MTA &c):

/home/$user/.forward:
|procmail -Y

This arranges for the mail to be fed through procmail.

/home/$user/.procmailrc:
:0f:
header=|formail -YczX From: -X To: -X Subject: -X Date:

:0bc:
|/home/$user/printmail "$header"

This extracts the listed headers, feeds a copy of the body of the mail
through the script, then delivers it to the default destination
(/var/spool/mail/$user).

/home/$user/printmail:
#!/bin/sh

cd
sox mailsound.wav -t ossdsp /dev/sound/dsp
(echo $1; echo; cat) | lpr
exit 0

This makes a noise (adjust as appropriate) and then sends the header, a
blank line and the body to the printer.

Ben
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top