1836882 Members
2050 Online
110111 Solutions
New Discussion

email to dir to web page

 
SOLVED
Go to solution
Michael Murphy_2
Frequent Advisor

email to dir to web page

Hello,

Has anyone out there had the occasion to want to have an email from another system be placed into a web server directory automatically? I believe that there is a way to modify an id to deal with mail diffently than just storing in a mailbox - but it has many years since I have seen this done - anyone doing this?
5 REPLIES 5
Mark Grant
Honored Contributor

Re: email to dir to web page

One way, perhaps, would be to use a symbolic link from the web server directory to the mailbox file.

More useful though would be a script to read your mailbox, do fancy html stuff with incoming mails and place them, pre-formatted in the directory you want.
Never preceed any demonstration with anything more predictive than "watch this"
Scott Van Kalken
Esteemed Contributor

Re: email to dir to web page

I did this with some system configuration stuff once a week a while ago.

As suggested, I did some pre formatting to include HTML tages etc, then just used ftp to automagically put it where I wanted it.

I found this a little easier than using procmail at the time.

I used ftp -i -n (from memory).

If you do want to use email, a neat way of doing it is to set up a mailbox on your server that automatically "prints" all incomming mails. Instead of sending them to a real printer, you can just send them to a script which does the formatting and places it in the correct spot (I've used this before as well - just remember to delete the email after processing if you don't want to keep them).

Hope this helps.

Scott.
Steven E. Protter
Exalted Contributor

Re: email to dir to web page

You can probably do that by configuring the sendmail deamon to store the mailfile for the user, usually /var/mail/username in the home directory of the web server.

Or you can make the documentroot on the httpd server equal the user name that owns the html docs /var/mail folder.

This may however present security problems.

I've tried to figure out why you want to do it, but I don't understand.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Bill Hassell
Honored Contributor
Solution

Re: email to dir to web page

Actually, this is fairly easy and I've done it to provide reports and FAQs on a regular basis. Since /var/mail files contain all the header junk and may contain multiple messages, I create a simple script to skip all the lines until the first blank one, insert
 as a preformat HTML tag and then store the rest of the message in an appropriate web location. For example:

/etc/mail/aliases:

tapefaq: " | /usr/contrib/bin/mail2 "

where mail2 is the above mentioned script. Be sure to run newaliases after editing the aliaases file. Also, the script is not run by root but by the daemon user (sendmail/rmail) so watch permissions and ownerships.


Bill Hassell, sysadmin
Mic V.
Esteemed Contributor

Re: email to dir to web page

I've done exactly what Bill describes; he got to it first. A few comments:
- I like Perl because it has good string handling
- I put the data written by the "mail catching" script in a place where permissions like daemon:other are not going to compromise the security of other code/data
- to perform some elementary validation, I typically examine some header field (such as sender or subject). It's not much, but it at least helps avoid random mail.
- I also use these scripts to perform processing, sometimes quite complicated, on the data that is mailed to them

In addition to using this method with a web server, I've also used it as a method to transfer data between systems. It queues when there are transmission problems and there is at least elementary logging ( /var/adm/syslog/mail.log ).

Mic
What kind of a name is 'Wolverine'?