| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
| |||
| |||
| Has anyone gotten "How do I change the sender address depending on the recipient?" from http://www.sendmail.org/~ca/email/lfaq.html#CHGADDR to work with a recent sendmail? I've tried to with no luck. I can see that it uses the mysmtp mailer from my syslog output. I also ended up not getting the rules to work, so I changed it to : # # sender rewriting for mysmtp # Smysmtp R$+ $: $>PseudoToReal $1 sender/ recipient common R$* :; <@> $@ list:; special case R$* $: $>MasqSMTP $1 qualify unqual'ed names R$* < @ *LOCAL* > $* $: $1 < @ some.example.net . > $2 use full name so it mirrored the current way smtp does it. Running a user through it seems to work well : > mysmtp tuc mysmtp input: tuc PseudoToReal input: tuc PseudoToReal returns: tuc MasqSMTP input: tuc MasqSMTP returns: tuc < @ *LOCAL* > mysmtp returns: tuc < @ some . example . net . > But it doesn't end up changing anything on the email itself. Any pointers to where I went wrong? I need to get this working to see if it will do what I want in the end. I'd like to be able to create a map like : fred@example.com fredexample@other.example.com mina@other.example.com minaother@other.example.com recruiter@example.com recruiter@other.example.com otherrecruiter@example.com recruiter@other.example.com So that if I email the first column, it changes the "From_" and "From:" to the 2nd column. Sort of an outbound virtusertable of sorts. Thanks, Tuc |
|
#2
| |||
| |||
| Hi, > Has anyone gotten "How do I change the sender address depending on the > recipient?" Do you really need to do this with sendmail ? I think procmail could do this nicely... FC. |
|
#3
| |||
| |||
| On Aug 22, 5:44 am, FC <f...@yahoo.fr> wrote: > Hi, > > > Has anyone gotten "How do I change the sender address depending on the > > recipient?" > > Do you really need to do this with sendmail ? I think procmail could do > this nicely... > > FC. I'd be interested to hear how to use procmail to send mail outbound. I've always only ever used it to process mail inbound. What I'm looking to do is change the "From_" and "From:" when I send mail out. (I use elm that feeds to a local sendmail that passes it to a SMARTHOST) Thanks, Tuc |
|
#4
| |||
| |||
| In article <79ba8bc9-512d-47cf-88b4-76a541555418@i76g2000hsf.googlegroups.com> Tuc <tuctboh@gmail.com> writes: > >so it mirrored the current way smtp does it. Running a user through it >seems to work well : > >> mysmtp tuc >mysmtp input: tuc >PseudoToReal input: tuc >PseudoToReal returns: tuc >MasqSMTP input: tuc >MasqSMTP returns: tuc < @ *LOCAL* > >mysmtp returns: tuc < @ some . example . net . > Wrong test case. The address won't be unqualified at that point with a current sendmail setup, since the MSP qualifies it with the local hostname before passing it to the MTA. Adding a rule R$* < @ $j > $* $: $1 < @ some.example.net . > might do the trick. (Using $=w instead of $j is another possibility, depending on what you want to achieve.) --Per Hedeland per@hedeland.org |
|
#5
| |||
| |||
| On Aug 23, 6:46 am, p...@hedeland.org (Per Hedeland) wrote: > In article > <79ba8bc9-512d-47cf-88b4-76a541555...@i76g2000hsf.googlegroups.com> Tuc > > <tuct...@gmail.com> writes: > > >so it mirrored the current way smtp does it. Running a user through it > >seems to work well : > > >> mysmtp tuc > >mysmtp input: tuc > >PseudoToReal input: tuc > >PseudoToReal returns: tuc > >MasqSMTP input: tuc > >MasqSMTP returns: tuc < @ *LOCAL* > > >mysmtp returns: tuc < @ some . example . net . > > > Wrong test case. The address won't be unqualified at that point with a > current sendmail setup, since the MSP qualifies it with the local > hostname before passing it to the MTA. Adding a rule > > R$* < @ $j > $* $: $1 < @ some.example.net . > > > might do the trick. (Using $=w instead of $j is another possibility, > depending on what you want to achieve.) > > --Per Hedeland > p...@hedeland.org Hi Per, Thanks for the reply. Couldn't get it to work unless I changed it to : R$* < @ $j . > $* $: $1 < @ some.example.net . > (Adding a "." after the "@ $j") I'm not sure if this was right or not, however, it did change it as I wante d it to. ![]() What I want to achieve, ultimately, is that I can create a table like : contact1@company1.example.com example1@example.com contact2@company2.example.com example2@example.com contact3@company2.example.com example2@example.com and when I email "contact3@company2.example.com" it changes my outbound ema il address as being "example2@example.com". I'm trying to use an example from Cl aus Abmann's FAQ called "How do I change the sender address depending on the recipient?" as a starting point. Right now in his example each destination email address would need its own : Rfriend<@some.domain.>$* $#mysmtp $@ some.domain. $: friend<@some.domain. >$1 line, and then each new mailer (mysmtp in this example) would need a new se t of rules to be able to change the email address. In the end, I'm trying to cobble together something that would do it all in 1 shot driven by a : # Outbound mail id Kmailid hash /etc/mail/mailid I'm trying to find my bat book with no luck, googling if someone else possi bly did exactly this with no viable hits (All seems to be done in milters). All the examples I find of using maps take (for example) sender and look up the sen der, and then can modify the sender. I haven't been able to see (or maybe just u nderstand) somewhere where I can take the receiver as the key, and modify the se nder. Thanks, Tuc |
|
#6
| |||
| |||
| In article <d3d63a09-5b73-4685-9025-665811f35a59@25g2000hsx.googlegroups.com> Tuc <tuctboh@gmail.com> writes: >On Aug 23, 6:46 am, p...@hedeland.org (Per Hedeland) wrote: >> >> Wrong test case. The address won't be unqualified at that point with a >> current sendmail setup, since the MSP qualifies it with the local >> hostname before passing it to the MTA. Adding a rule >> >> R$* < @ $j > $* $: $1 < @ some.example.net . > >> >> might do the trick. (Using $=w instead of $j is another possibility, >> depending on what you want to achieve.) > Thanks for the reply. Couldn't get it to work unless I changed it >to : > >R$* < @ $j . > $* $: $1 < @ some.example.net . > > >(Adding a "." after the "@ $j") Yes, that's right - sendmail adds a trailing dot when "canonicalization" has been successful (normally == "name found in DNS"). > I'm trying to find my bat book with no luck, googling if someone >else possi >bly did exactly this with no viable hits (All seems to be done in >milters). All > the examples I find of using maps take (for example) sender and look >up the sen >der, and then can modify the sender. I haven't been able to see (or >maybe just u >nderstand) somewhere where I can take the receiver as the key, and >modify the se >nder. This is non-trivial I think. Basically all the rewriting rules operate on one address at a time - it still pretty easy to get hold of the (envelope) sender address ($&f) when you're processing a recipient address, because there is only one sender address - but there can (of course) be multiple recipient addresses, so the reverse is not true. A milter is probably the best way to go. --Per Hedeland per@hedeland.org |
|
#7
| |||
| |||
| On Aug 26, 4:19 pm, p...@hedeland.org (Per Hedeland) wrote: > In article > <d3d63a09-5b73-4685-9025-665811f35...@25g2000hsx.googlegroups.com> Tuc > > > > <tuct...@gmail.com> writes: > >On Aug 23, 6:46 am, p...@hedeland.org (Per Hedeland) wrote: > > >> Wrong test case. The address won't be unqualified at that point with a > >> current sendmail setup, since the MSP qualifies it with the local > >> hostname before passing it to the MTA. Adding a rule > > >> R$* < @ $j > $* $: $1 < @ some.example.net . > > > >> might do the trick. (Using $=w instead of $j is another possibility, > >> depending on what you want to achieve.) > > Thanks for the reply. Couldn't get it to work unless I changed it > >to : > > >R$* < @ $j . > $* $: $1 < @ some.example.net . > > > >(Adding a "." after the "@ $j") > > Yes, that's right - sendmail adds a trailing dot when "canonicalization" > has been successful (normally == "name found in DNS"). > > > I'm trying to find my bat book with no luck, googling if someone > >else possi > >bly did exactly this with no viable hits (All seems to be done in > >milters). All > > the examples I find of using maps take (for example) sender and look > >up the sen > >der, and then can modify the sender. I haven't been able to see (or > >maybe just u > >nderstand) somewhere where I can take the receiver as the key, and > >modify the se > >nder. > > This is non-trivial I think. Basically all the rewriting rules operate > on one address at a time - it still pretty easy to get hold of the > (envelope) sender address ($&f) when you're processing a recipient > address, because there is only one sender address - but there can (of > course) be multiple recipient addresses, so the reverse is not true. > A milter is probably the best way to go. > > --Per Hedeland > p...@hedeland.org Hi Per, Thanks again for the reply. I'm PRETTY willing to give it up after 1 more try. ![]() I went back to OP and saw the $f (It is $f, right? I couldn't find $&f) is the sender. And I do understand that there can be multiple recipients, but lets for the minute ignore that aspect. What I was previously doing in the cf was setting : Kmailid hash /etc/mail/mailid and then hand inserting into the very bottom of Sfinal=4 the following : R$-@example.com $:$(mailid $1 $: $1@example.com $) I took this to mean : set $1 to whats before "@example.com". If the address is *@example.com, then go against mailid with the $1. If there was a match, set it to what was returned. If there wasn't a match, set it to $1@example.com (What it was set to already effectively). If my line of reasoning and thinking is right, then I should be able to create a file : /etc/mail/virtout someuser@foreign.example.com mynewsender@example.com add Kvirtout hash /etc/mail/virtout and change the rule to : R$* $:$(virtout $u $: $1 $) shouldn't that effectively accomplish what I want. (Answer is I've tried and it doesn't, so I'm wondering what I did wrong. Is $u in a format I don't get, etc) If you/anyone can't point out the glaring mistake, I pack it up and go to milters. ![]() Thanks, Tuc |
|
#8
| |||
| |||
| On Aug 26, 8:33 pm, Tuc <tuct...@gmail.com> wrote: > On Aug 26, 4:19 pm, p...@hedeland.org (Per Hedeland) wrote: > > > > > In article > > <d3d63a09-5b73-4685-9025-665811f35...@25g2000hsx.googlegroups.com> Tuc > > > <tuct...@gmail.com> writes: > > >On Aug 23, 6:46 am, p...@hedeland.org (Per Hedeland) wrote: > > > >> Wrong test case. The address won't be unqualified at that point with a > > >> current sendmail setup, since the MSP qualifies it with the local > > >> hostname before passing it to the MTA. Adding a rule > > > >> R$* < @ $j > $* $: $1 < @ some.example.net . > > > > >> might do the trick. (Using $=w instead of $j is another possibility, > > >> depending on what you want to achieve.) > > > Thanks for the reply. Couldn't get it to work unless I changed it > > >to : > > > >R$* < @ $j . > $* $: $1 < @ some.example.net . > > > > >(Adding a "." after the "@ $j") > > > Yes, that's right - sendmail adds a trailing dot when "canonicalization" > > has been successful (normally == "name found in DNS"). > > > > I'm trying to find my bat book with no luck, googling if someone > > >else possi > > >bly did exactly this with no viable hits (All seems to be done in > > >milters). All > > > the examples I find of using maps take (for example) sender and look > > >up the sen > > >der, and then can modify the sender. I haven't been able to see (or > > >maybe just u > > >nderstand) somewhere where I can take the receiver as the key, and > > >modify the se > > >nder. > > > This is non-trivial I think. Basically all the rewriting rules operate > > on one address at a time - it still pretty easy to get hold of the > > (envelope) sender address ($&f) when you're processing a recipient > > address, because there is only one sender address - but there can (of > > course) be multiple recipient addresses, so the reverse is not true. > > A milter is probably the best way to go. > > > --Per Hedeland > > p...@hedeland.org > > Hi Per, > > Thanks again for the reply. I'm PRETTY willing to give it up > after 1 more > try. ![]() > > I went back to OP and saw the $f (It is $f, right? I couldn't > find $&f) is the > sender. And I do understand that there can be multiple recipients, but > lets for > the minute ignore that aspect. > > What I was previously doing in the cf was setting : > > Kmailid hash /etc/mail/mailid > > and then hand inserting into the very bottom of Sfinal=4 the > following : > > R...@example.com $:$(mailid $1 $: $...@example.com $) > > I took this to mean : > > set $1 to whats before "@example.com". If the address is > *...@example.com, > then go against mailid with the $1. If there was a match, set it to > what was returned. > If there wasn't a match, set it to $...@example.com (What it was set to > already > effectively). > > If my line of reasoning and thinking is right, then I should be > able to create a > file : > > /etc/mail/virtout > someu...@foreign.example.com mynewsen...@example.com > > add > > Kvirtout hash /etc/mail/virtout > > and change the rule to : > > R$* $:$(virtout $u $: $1 $) > > shouldn't that effectively accomplish what I want. (Answer is I've > tried and > it doesn't, so I'm wondering what I did wrong. Is $u in a format I > don't get, etc) > > If you/anyone can't point out the glaring mistake, I pack it up > and go to milters. ![]() > > Thanks, Tuc Ok, a bit of an update..... I did find that $&f is valid, sorry about that. If I replace the "mailid" rule with R$* $:$(variout $&u $: $1 $) in Sfinal=4, I get a weird thing happening. 1) Doesn't change the "Return-Path" (When viewed in Yahoo!), which my old mailid did. 2) Changes the sender to what I want (YEAH!) 3) Changes the recipient to what it changes the sender to (BOO!) I figured that #3 was a side effect of putting it in Sfinal=4 when it belongs in SParseLocal=98 I think. Why #1 isn't changing, THAT I'm totally puzzled about.... If I do put it in SParseLocal=98, nothing happens ANYWHERE. :-/ Tuc |
|
#9
| |||
| |||
| Tuc wrote: > On Aug 22, 5:44 am, FC <f...@yahoo.fr> wrote: >> Hi, >> >>> Has anyone gotten "How do I change the sender address depending on the >>> recipient?" >> Do you really need to do this with sendmail ? I think procmail could do >> this nicely... >> >> FC. > > I'd be interested to hear how to use procmail to send mail outbound. Include a line reading MAILER(`procmail')dnl in your .mc file. Select this mailer for specific recipients like you selected a modified SMTP mailer as described by Claus Assmann in http://www.sendmail.org/~ca/email/lfaq.html Don't confuse MAILER(`procmail') with procmail used as the local delivery agent through FEATURE(`local procmail'). On Linux systems FEATURE(`local procmail') is often included -in a way not directly visible- through the use of OSTYPE(`linux'). I never used this myself, so don't expect too much details from me. At a first glance I think you need to define a configuration file (by defining "PROCMAIL_MAILER_ARGS"). The default /etc/procmailrc might interfere with your use of procmail as a local delivery agent. See the procmail(1) and procmailrc(5) manpages for further details. See the procmailex(5) and formail(1) manpages for examples how to use procmail and formail to resubmit messages with modified/replaced header lines. > I've always only ever used it to process mail inbound. What I'm > looking to do is change the "From_" and "From:" when I send mail out. > (I use elm that feeds to a local sendmail that passes it to a > SMARTHOST) > > Thanks, Tuc |
|
#10
| |||
| |||
| In article <eef86a1d-192a-4002-9fc4-462b4974c130@8g2000hse.googlegroups.com> Tuc <tuctboh@gmail.com> writes: > >I did find that $&f is valid, sorry about that. Yes, $<macro> gets interpreted at cf-reading time, $&<macro> delays the interpretation until actual processing. >If I replace the "mailid" rule with > >R$* $:$(variout $&u $: $1 $) > >in Sfinal=4, I get a weird thing happening. > >1) Doesn't change the "Return-Path" (When viewed in Yahoo!), which my >old mailid did. Somewhat strange, all addresses should be passed through S4 at the end, but there's probably some explanation... A good test to see exactly how the different envelope/header sender/recipient addresses are run through the different rulesets is to run something like (as root) (echo To: <header-recipient>; echo From: <header-sender>) | sendmail -Am -odi -d21.<x> -f <envelope-sender> <envelope-recipient> Replace <x> with a number depending on how much detail you want, e.g. start at 2 and go up, and replace the <addresses> with real ones - but for maximum illumination, use different ones for header vs envelope. (It's the envelope sender that eventually ends up in Return-Path.) >2) Changes the sender to what I want (YEAH!) >3) Changes the recipient to what it changes the sender to (BOO!) That is to be expected. >I figured that #3 was a side effect of putting it in Sfinal=4 when it >belongs in SParseLocal=98 No it doesn't - S0 (ParseLocal is a "subruleset" of S0) is for the routing decisions, what you do there will affect the envelope recipient address - but this doesn't normally appear in the final message (except possibly as a "for" in a Recieved header). (The envelope sender address is actually run through S0 too, but the result doesn't affect the final message except if you use some "unusual" mailer flags...) You may want to try the mailer S= rulesets (envelope/header) as you are playing with a special mailer anyway. But in any case you will have the problem that if there are multiple recipients, $u (a.k.a. $&u) will not be set. Or at least that's the case for the "normal" rulesets - I think it's the same in the mailer-specific ones. And of course if you have multiple recipients and haven't split them out to separate mailers, you may have conflicting requirements for the sender... --Per Hedeland per@hedeland.org |
![]() |
| Thread Tools | |
| Display Modes | |
In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.