Go Back   { mindfrost82.com } > Gadget Corner > Tech Newsgroups > Linux > RedHat

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-25-2008, 06:40 PM
Jason Maur
 
Posts: n/a
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
Reply With Quote
  #2 (permalink)  
Old 02-26-2008, 01:52 AM
Jamie
 
Posts: n/a
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
Reply With Quote
  #3 (permalink)  
Old 03-03-2008, 04:39 PM
Jason Maur
 
Posts: n/a
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


Reply With Quote
Reply

  { mindfrost82.com } > Gadget Corner > Tech Newsgroups > Linux > RedHat


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 11:47 PM.


Powered by vBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
© 1999-2008 mindfrost82.com v11.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108