On Fri, Feb 16, 2001 at 10:36:47AM +0000, Gerard J Keating wrote:
> hopefully someone can give me some pointers.
Pointers, yes, but not a full answer, but only because I've never done
exactly what you want - I know that what I tell you below will do the job.
> I have a file arriving daily to a email address on my linux server with a file
> attachment. What i want to do is have the attached file coping to a certian
> directory when the email arrives, how would i do this. Also want to run a
> program to process this file.
The tools for the job are mimencode, and possibly procmail. You need to pipe
the incoming mail through mimencode -u which will decode the message i.e.
remove the attachment. A little reading of the man page and experimentation
will sort that out for you, and of course it's a trivial matter then to put
the resultant file into whatever directory you need.
So, how to get the email to the script ? Well, if the email address is a
role address, i.e. it's a special address just to receive this daily email,
or you can make it be that way, then your life is simpler. Assume the email
is addressed to logger at fintrax.com, then in logger's home directory simply
create a file called .forward with the following content
When mail is received for logger, your script will be run with the mail
message as STDIN.
If OTOH this is just one mail of many for a particular user, then you'll
need to setup procmail for that user. procmail will filter all incoming mail
and do various things with it e.g. put all ILUG mail in an ILUG mailbox,
throw spam in the bin etc. etc. In this case, you'd configure procmail to
recognise these special mails and run your script on them. You'll have to do
some reading on procmail, of course :-)
Hope this has been of some help.
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!