Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Route every single incoming email to a perl script 1

Status
Not open for further replies.

ruttiger

Programmer
Nov 16, 2000
24
US
I'm going to host many different domains' emails. new domain partners and email users will sign up all the time, and i'd rather not have to modify my sendmail configuration scripts. how can i tell sendmail to output the contents of every single email to a script, regardless of domain or username? i'll let the script take care of all that responsibility, i just need to know how to route to it.

thanks much in advance,

blake.
 
Not sure you can do that without modifying the source code.

The Sendmail people are probably sick of hearing me say this (hehe) but I feel I must since their alternative is so dang complicated.

If you want to handle email for multiple domains you really really should look into qmail/vpopmail.


Trying to handle multiple domains with sendmail is just asking for a migrane (just ask the friendly folks at Cobalt... heh... )

You will find people receiving email that was not meant for them if it is received at all. :eek: tsk tsk

I was in charge of about 15 multiple-domain email servers, and I spent about 60% of my day dealing with email problems on those servers.

Since I switched to qmail/vpopmail I may spend 20 minutes a day on issues, mostly related to people not setting up their email clients correctly. qmail has not crashed on me yet and it has been over 6 months.

Regards,
Gerald
 
ugh. thanks. yeah, i was using qmail on my home linuxbox to test, and it seemed very easy. I just started hosting at rackspace, and i dont think they 'support' it. you might be right. if there's any viable solution with sendmail, aside from modifying the source code, i'll use it, cause it seems sendmail is the most powerful program of its kind...

qmail is the last resort.

if i find the solution, i'll post it here.
thanks much,

blake
 
Well, question for ya, can i have both qmail and sendmail both on the same system? i'd like to keep sendmail for sending emails. does it require any daemons for that? or, does qmail do a fine job of sending?

my server techs say i can't have both installed, and they'll only support sendmail. tough decision, i just wanna know everything about it.

thanks again
 
well if you can install both in completely seperate places, it should be possible to use sendmail to send email ... but it's not exactly worth the hassle ...

you won't be able to run both qmail and sendmail in daemon mode at the same time ... so that if you tried sending with sendmail you would have to set it up to deliver directly, but you would have to use the local host to talk directly to it ... external machines woun't be able to talk to it directly ...

all in all ... use one or the other ... it gets _very_ messy otherwise ...
 
Well, thanks for all the help. i decided not to take the easy way out (qmail), but to go with the more standard and powerful Sendmail.

Since you guys helped me out, if you're interested, here's how i'm using sendmail to accept and process emails from different domains with a single perl script, and minimal entries in the config files:

I've gotten it all to work. For each new sub/domain i add, i just append it to the /etc/sendmail.cw file. Then i append:
@mydomain.com email-script-user

to /etc/mail/virtusertable
to route every email address from mydomain.com to the email alias 'email-script-user'.
the alias 'email-script-user' routes all emails to a perl script on my server, which decides what to do with the email. The problem was that by looking at the headers of the email sent to my script through STDIN, i couldn't tell who the email was from. Like, if it was someone in the CC or BCC, i wouldn't know. Sendmail doesnt post ENV vars like qmail does (wish it did)...so, i went into /etc/sendmail.cf, and added my own header,
HX-Intended-Recipient: $u

this gives me a header in all received (and consequently) sent email like this:
X-Intended-Recipient: <user@emailaddress.com>
this user might not even be in the headers, as s/he might be a BCC recipient. The X- is kinda required, because other programs will ignore it if they dont know what it is. So, now that i have that special header, all's good, my perl script can handle it all very easily.

And, i'm sure qmail has a good queue manager too, but, if i have to edit the perl script, i just put up a dummy script in it's place that has this:

exit(75);

which is the system message : 'temporary failure', which tells sendmail to put the email in the queue, and try for local delivery later.

So, i ended up reading a good chunk of the O'Reilly book, and learned a whole lot. Now that i know more, I'd have to recommend Sendmail, if the time to learn it was there...it seems to be pretty powerful.

but, took me 3 days to do something i learned in qmail in 1 hour...weigh the consequences.

well, if you all weren't interested, sorry - else, thanks much for the help!

-blake
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top