![]() |
|
|
|||
|
Linux, mySQL and e-mail server question
This is a general question, mainly because I
don't know what to search for to do what I want... I have a dedicated web server running Fedora 5 that has a exim mail server running, as well as a mysql 4.1.22 database. Basically, I would like to have a daemon running that logs all incoming and outgoing e-mail into the database. Well, not all e-mail, just e-mails from previous or current clients. The flow of this program would be something like this: - Detect that an e-mail has been received. - Check the database to see if a client exists with that e-mail, and if there is one, then insert a row into the database containing the message of the text and other info. Any ideas? Ideally, there is some event that I can catch (i.e., when an e-mail is sent or received through the mail server) that will let me run an external program when said event happens. For example: onReceiveEmail || onSentEmail: php /my/email/handing/script.php Is this possible? Any information would be useful. Thanks in advance, -Jason |
|
|||
|
Re: Linux, mySQL and e-mail server question
In <GpKdnWFoff4Hh17anZ2dnUVZ_o3inZ2d@giganews.com>,
Jason Maur <jmaumau@yahoo.com> mentions: >This is a general question, mainly because I >don't know what to search for to do what I want... > >I have a dedicated web server running Fedora 5 >that has a exim mail server running, as well as >a mysql 4.1.22 database. Basically, I would like >to have a daemon running that logs all incoming >and outgoing e-mail into the database. Well, not >all e-mail, just e-mails from previous or current >clients. The flow of this program would be something >like this: > >- Detect that an e-mail has been received. >- Check the database to see if a client exists with > that e-mail, and if there is one, then insert a row > into the database containing the message of the text > and other info. > >Any ideas? Ideally, there is some event that I can >catch (i.e., when an e-mail is sent or received through >the mail server) that will let me run an external program >when said event happens. For example: > >onReceiveEmail || onSentEmail: php /my/email/handing/script.php Just to let you know.. it IS possible with exim, years ago I had something like that. It involved an awful lot of configuration and specialty scripts though. You have to get real familiar with your exim config file, transports and routers. (in my case, I had it routed through spamassassin too.. made it overly complicated and I ended up going with something easier) As far as Received email, you can use exim filters, something like this in a filter: unseen pipe /my/special/program.pl Next is to get all email to go through this filter. If you just want those addressed to a given person, it's trivial: if $header_to: contains "client@example.com" then unseen pipe program.pl endif As far as where this filter goes, it *probably* is set up as your .forward file, but, you can change it: Something like this will seek out a ~/exim_filter.conf userforward: driver=redirect check_local_user file = $home/exim_filter.conf (Look in your exim.conf file, I'm guessing it'll be .forward if it is defined) I'd strongly consider placing incomming mail into a separate queue and processing it later, you don't need your whole email system to fall apart because a database isn't running. (Hint: you could pipe it into a program that just spools it and launches another command via 'batch' later on, since batch won't run until the machine is idle) I like batch, too bad it's under utilized! :-) That takes care of the *received* email going to a special program, but as far as outbound email, I don't remember. (that part was convoluted and I ended up just settling on a fcc: mbox ala-mutt) If you run exim with verbose debugging, you can examine the log file and see the relationships between the various routers and transports. That'll give you enough to go on when it's time to read through the exim documentation. Jamie -- http://www.geniegate.com Custom web programming Perl * Java * UNIX User Management Solutions |
|
|||
|
Re: Linux, mySQL and e-mail server question
Jamie,
Thanks for the input. I figured I'd put the solution I came up with for handling all outgoing e-mails, and see what people think (hopefully this solution is good and can help people): In the exim.conf file (/etc/exim.conf in my case), I looked for a line beginning with 'system_filter', which tells me the filename of system wide filters. I then added the following to said file: if $sender_address_domain is mydomain.com and ${mask:$sender_host_address/24} is 192.168.324.0/24 then unseen deliver mailbox@whatever.domain endif Then I setup the e-mail account mailbox@whatever.domain to forward all e-mail to /home/me/myoutgoingscript.php. Anybody see any problems with said solution? Thanks, Jason Jamie wrote: > In <GpKdnWFoff4Hh17anZ2dnUVZ_o3inZ2d@giganews.com>, > Jason Maur <jmaumau@yahoo.com> mentions: >>This is a general question, mainly because I >>don't know what to search for to do what I want... >> >>I have a dedicated web server running Fedora 5 >>that has a exim mail server running, as well as >>a mysql 4.1.22 database. Basically, I would like >>to have a daemon running that logs all incoming >>and outgoing e-mail into the database. Well, not >>all e-mail, just e-mails from previous or current >>clients. The flow of this program would be something >>like this: >> >>- Detect that an e-mail has been received. >>- Check the database to see if a client exists with >> that e-mail, and if there is one, then insert a row >> into the database containing the message of the text >> and other info. >> >>Any ideas? Ideally, there is some event that I can >>catch (i.e., when an e-mail is sent or received through >>the mail server) that will let me run an external program >>when said event happens. For example: >> >>onReceiveEmail || onSentEmail: php /my/email/handing/script.php > > Just to let you know.. it IS possible with exim, years ago I had > something like that. It involved an awful lot of configuration > and specialty scripts though. You have to get real familiar with > your exim config file, transports and routers. (in my case, I had it > routed through spamassassin too.. made it overly complicated and I > ended up going with something easier) > > As far as Received email, you can use exim filters, something like > this in a filter: > > unseen pipe /my/special/program.pl > > Next is to get all email to go through this filter. If you just want > those addressed to a given person, it's trivial: > > if $header_to: contains "client@example.com" > then > unseen pipe program.pl > endif > > As far as where this filter goes, it *probably* is set up as your .forward > file, but, you can change it: > > Something like this will seek out a ~/exim_filter.conf > > userforward: > driver=redirect > check_local_user > file = $home/exim_filter.conf > > (Look in your exim.conf file, I'm guessing it'll be .forward if it is > defined) > > I'd strongly consider placing incomming mail into a separate queue and > processing it later, you don't need your whole email system to fall apart > because a database isn't running. (Hint: you could pipe it into a program > that just spools it and launches another command via 'batch' later on, > since batch won't run until the machine is idle) I like batch, too bad > it's under utilized! > :-) > > That takes care of the *received* email going to a special program, but as > far as outbound email, I don't remember. (that part was convoluted and I > ended up just settling on a fcc: mbox ala-mutt) > > If you run exim with verbose debugging, you can examine the log file and > see the relationships between the various routers and transports. That'll > give you enough to go on when it's time to read through the exim > documentation. > > Jamie |
![]() |
|
| Thread Tools | Search this Thread |
| Display Modes | |
|
|