LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 01-09-2009, 02:05 PM   #1
catalytical
LQ Newbie
 
Registered: Jan 2009
Posts: 3

Rep: Reputation: 0
Sendmail recipient address rewriting question...


We have customers who regularly enter the wrong domain for their email address during the purchase process. A very simple example is someone entering @hotmai.com instead of @hotmail.com for the domain portion of the email.

Why is this a concern? Well, not only do the customers not get their purchase receipt, the mail server gets tied up with these addresses because there is an A record, but no MX record for these bogus domains, and so it gets "connection refused", which it takes as a "I need to retry this" and as such retries for the set amount of days (which I have lowered to 2). Because of the volume of mail from the commerce server, and the fact that it delivers virtual goods, the queue runner is going every 10 minutes to clear the queue - which means it retries these addresses every 10 minutes. Under periods of high load, I need sendmail to focus on sending good mail and not the bad stuff.

The email addresses are entered via a form in PHP, and then the PHP application calls sendmail to send the customer a receipt. While we could do something in PHP, my developers are busy right now and I'd just like to find a way to do this via some kind of mechanism in Sendmail.

Sendmail rulesets seemed like the way to rewrite the domain portion of the email, but I just can't get them working. First, I have NO idea where in the chain of rulesets in sendmail.cf to insert the right rule (I can't see rulesets at all in sendmail.mc, or I'd put it there). Can someone tell me WHERE *exactly* in sendmail.cf I should put this kind of rewrite? Secondly, I'm totally uncertain how to write the rule.

I started out with

R$- @ yagoo.com $1 @ yahoo.com

But this may not be correct due to the fact that angle brackets <> show up at some point in the email address and I'm not totally familiar with where in the email flow to do this kind of rewrite and how to include angle brackets if they are in the email address.

I tried putting it right after the start of ruleset 3 in the sendmail.cf -it did nothing. I tried inserting it in various other places with no effect.

I tried using the virtusertable, but that didn't rewrite the address.

Any help would be much appreciated.

-Cat.
 
Old 01-11-2009, 04:42 AM   #2
georgekraj
LQ Newbie
 
Registered: Dec 2007
Location: India
Distribution: RHEL 5.0
Posts: 27

Rep: Reputation: 16
Hi,
You can use virtusertable feature of sendmail in this scenario. Just check for the syntax correctly.

Make sure you enabled the virtusertable feature

To configure the virtusertable feature, add the feature to your sendmail.mc configuration as shown:
FEATURE(virtusertable)


By default, the file containing the rules to perform translations will be /etc/mail/virtusertable.

The following example shows three possible types of entries:
samiam@bovine.net colin
sunny@bovine.net darkhorse@mystery.net
@dairy.org mail@jhm.org
@artist.org $1@red.firefly.com
@yagoo.com $1@yahoo.com

In this example, we are virtual hosting three domains: bovine.net, dairy.org, and artist.org.

The first entry redirects mail sent to a user in the bovine.net virtual domain to a local user on the machine. The second entry redirects mail to a user in the same virtual domain to a user in another domain. The third example redirects all mail addressed to any user in the dairly.org virtual domain to a single remote mail address. Finally, the fourth entry redirects any mail to a user in the artist.org virtual domain to the same user in another domain; for example, julie@artists.org would be redirected to julie@red.firefly.com.
 
Old 01-11-2009, 06:09 AM   #3
unSpawn
Moderator
 
Registered: May 2001
Posts: 26,944
Blog Entries: 54

Rep: Reputation: 2731Reputation: 2731Reputation: 2731Reputation: 2731Reputation: 2731Reputation: 2731Reputation: 2731Reputation: 2731Reputation: 2731Reputation: 2731Reputation: 2731
Quote:
Originally Posted by catalytical View Post
We have customers who regularly enter the wrong domain for their email address during the purchase process. (..) The email addresses are entered via a form in PHP, and then the PHP application calls sendmail to send the customer a receipt.
In short: a good design and use of common sense should prevail over applying kludges, bandaids or workarounds and reasoning the other way around. Your MTA should not be the place to validate data entered by users but your PHP application:
- From a business perspective the buyer is responsable for entering the right information. For instance you validate credit card information in the frontend and reject if the data is incorrect. So why should that be different for other validation?
- If you know secure coding principles then you know that when you are confronted with trusing user input there are two schools: one says it's OK to modify user input before usage and other tells you that you should not. Practically speaking the question you would want to ask yourself is: based on exactly what assumptions am I allowed to make decisions for my customers?. From your example of "R$- @ yagoo.com $1 @ yahoo.com" you would need a table mapping all permutations and some logic to determine if the domain meant is yahoo.com or really yaboo.com, yacoo.com, yagoo.com, yaioo.com, yaloo.com, yaqoo.com, yaroo.com, yauoo.com, yaxoo.com, yayoo.com, yazoo.com? Like the previous reply shows that works OK if you know both "wrong" and "right" domainnames. Yes you can guess it, but in essence you don't know.
- Finally, any form of unvalidated mapping like that will be high maintenance, incomplete and thus errorprone.
Even shorter: do things like they should be done.



Quote:
Originally Posted by catalytical View Post
we could do something in PHP, my developers are busy right now
If you're paying them that's not a reason. IMHO.
 
Old 01-12-2009, 07:22 AM   #4
catalytical
LQ Newbie
 
Registered: Jan 2009
Posts: 3

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by unSpawn View Post
In short: a good design and use of common sense should prevail over applying kludges, bandaids or workarounds and reasoning the other way around. Your MTA should not be the place to validate data entered by users but your PHP application:
I agree completely, however other business priorities which have the developers on a schedule (and good development practices, which mean new features have to be worked into that schedule via a plan) preclude me from diverting them for this enhancement for at least 4 weeks and possibly longer. As such, a temporary workaround was what I was looking for in the interim, until this can be addressed at the user input level.

I am aware that the "kludge" would not catch everything - I was looking to rewrite the small percentage of commonly known bad addresses that result in 80% of the soft bounces.

As for the previous poster, who suggested Virtusertable, I have tried that without success. I wonder if it is intended for inbound mail to domains mapped to the current box - not for outbound mail intended for a non-local domain. I put in the entries as specified and a sendmail -bt produces the following (as you can see, it does not result in a transformed address, and it does not seem to use virtusertable, even though the feature is enabled in the sendmail.mc file (and compiled to sendmail.cf)):

# sendmail -bt
ADDRESS TEST MODE (ruleset 3 NOT automatically invoked)
Enter <ruleset> <address>
> 3,0 someemail@yagoo.com
canonify input: someemail @ yagoo . com
Canonify2 input: someemail < @ yagoo . com >
yagoo.com: Name server timeout
Canonify2 returns: someemail < @ yagoo . com >
canonify returns: someemail < @ yagoo . com >
== Ruleset 3,0 (3) status 75
parse input: someemail < @ yagoo . com >
Parse0 input: someemail < @ yagoo . com >
Parse0 returns: someemail < @ yagoo . com >
ParseLocal input: someemail < @ yagoo . com >
ParseLocal returns: someemail < @ yagoo . com >
Parse1 input: someemail < @ yagoo . com >
Mailertable input: < yagoo . com > someemail < @ yagoo . com >
Mailertable input: yagoo . < com > someemail < @ yagoo . com >
Mailertable returns: someemail < @ yagoo . com >
Mailertable returns: someemail < @ yagoo . com >
MailerToTriple input: < > someemail < @ yagoo . com >
MailerToTriple returns: someemail < @ yagoo . com >
Parse1 returns: $# esmtp $@ yagoo . com $: someemail < @ yagoo . com >
parse returns: $# esmtp $@ yagoo . com $: someemail < @ yagoo . com >

Then again, perhaps I am testing it against the wrong ruleset?

-C.
 
Old 01-12-2009, 05:40 PM   #5
unSpawn
Moderator
 
Registered: May 2001
Posts: 26,944
Blog Entries: 54

Rep: Reputation: 2731Reputation: 2731Reputation: 2731Reputation: 2731Reputation: 2731Reputation: 2731Reputation: 2731Reputation: 2731Reputation: 2731Reputation: 2731Reputation: 2731
If sendmail.mc has "FEATURE(domaintable)dnl" then "yagoo.com yahoo.com"-like mappings in /etc/mail/domaintable should make 'echo "3,0 user@yaboo.com" | /usr/sbin/sendmail -v -bt' show the rewrite.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
address rewriting method haariseshu Linux - Server 1 08-21-2008 11:01 PM
Postfix whitelisting by recipient address? carlmarshall Linux - Server 4 12-07-2006 07:12 AM
Recipient address rejected gabsik Linux - Networking 2 10-18-2006 12:45 PM
Recipient gets different address gubak Linux - Networking 3 02-11-2005 12:41 PM
postfix - wrong recipient address iliah Linux - Networking 2 09-26-2004 09:34 AM


All times are GMT -5. The time now is 07:19 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration