PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Logiciels d'hébergement > mailing.postfix.users > Rewrite Address Based on _Recipient_
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Rewrite Address Based on _Recipient_

Réponse
 
LinkBack Outils de la discussion
Vieux 10/03/2006, 03h09   #1
s.fenster@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Rewrite Address Based on _Recipient_

Hi. I want to know if there is a way to rewrite the sender address
based on the recipient of the address.

So for example, if the email is addressed to a@domain.com, re-write the
from address to x@domain.com. Otherwise, keep the sender address as it
is.

I was looking at sender_canonical and regular expressions, but it looks
like it applies the regular expression matching pattern to the sender
address and rewrites the sender address. I want to apply the regular
expression to the recipient but rewrite the sender address.

I ultimately want to use the virtual table to redirect email for
a@domain.com to some other email address, but instead of retaining the
original sender address, I want to change the sender address.

Any ideas on how to do this?

Thanks,
Seth

  Réponse avec citation
Vieux 10/03/2006, 23h36   #2
Greg Hackney
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Rewrite Address Based on _Recipient_


I don't think this can be done using just Postfix alone.

Postfix can do canonical mapping of sender addresses, and of recipient addresses,
but not do one depending on the value of another.

--
Greg



s.fenster@gmail.com wrote:
> Hi. I want to know if there is a way to rewrite the sender address
> based on the recipient of the address.
>
> So for example, if the email is addressed to a@domain.com, re-write the
> from address to x@domain.com. Otherwise, keep the sender address as it
> is.
>
> I was looking at sender_canonical and regular expressions, but it looks
> like it applies the regular expression matching pattern to the sender
> address and rewrites the sender address. I want to apply the regular
> expression to the recipient but rewrite the sender address.
>
> I ultimately want to use the virtual table to redirect email for
> a@domain.com to some other email address, but instead of retaining the
> original sender address, I want to change the sender address.
>
> Any ideas on how to do this?
>
> Thanks,
> Seth
>

  Réponse avec citation
Vieux 11/03/2006, 04h04   #3
s.fenster@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Rewrite Address Based on _Recipient_

Thanks Greg.

Do you have any recommendations on how I can do this with other
programs? Would procmail do this?

Right now I have Outlook forwarding the emails based on a rule
template, but this is cheesy, since I have to have a computer logged in
all of the time.

Thanks,

Seth

  Réponse avec citation
Vieux 11/03/2006, 14h30   #4
Greg Hackney
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Rewrite Address Based on _Recipient_


You could do it easily with procmail and formail.

In the example below (assuming that I understand what you want to do):

recipient@domain.com is the original recipient address
sender@domain.com is the new forced sender address you want to use
newaccount@domain.com is the new recipient address you want the email forwared to



--< ~recipient/.forward >--
|"exec /usr/bin/procmail"

--< ~recipient/.procmailrc >--
:0fw
| /usr/bin/formail -i "From: SENDER_NAME <sender@domain.com>" | /usr/lib/sendmail -f sender@domain.com newaccount@domain.com


--
Greg




s.fenster@gmail.com wrote:
> Thanks Greg.
>
> Do you have any recommendations on how I can do this with other
> programs? Would procmail do this?


  Réponse avec citation
Vieux 11/03/2006, 18h21   #5
s.fenster@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Rewrite Address Based on _Recipient_

That looks like greek to me; I don't know anything about procmail. But
I will study up on it. From your suggestion, it looks like procmail is
the way to go. Thanks!

  Réponse avec citation
Vieux 12/03/2006, 07h06   #6
s.fenster@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Rewrite Address Based on _Recipient_

Greg,

I used your recipe and it worked beautifully. I had to tweak it. For
some reason, the fax service wasn't recognizing the recipient address.
I was sending it to myfaxnumber@faxservice.com. The emailed response
was "no valid fax number found in message". I tried using
faxnumber@faxservice.com, faxnumber@faxservice.com
<faxnumber@faxservice.com>, and just <faxnumber@faxservice.com>. None
of them worked. I don't know what format it was expecting, or what
format the recipient parameter in sendmail expects.

I did get it to work by using the -A option in formail to append the
"To" address and the -t option in sendmail to extract the "To" address.

Thanks for your !

Seth

  Réponse avec citation
Vieux 12/03/2006, 16h58   #7
Greg Hackney
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Rewrite Address Based on _Recipient_

s.fenster@gmail.com wrote:

> For some reason, the fax service wasn't recognizing the recipient address.
> I did get it to work by using the -A option in formail to append the
> "To" address and the -t option in sendmail to extract the "To" address.


I can explain why it wasn't working. But it's long winded:

There are two different types of addresses. There are envelope addresses, and there
are header addresses. You can think of these along the lines of a postal letter:

On the outside of the postal letter, it shows where the email is to be delivered to,
and the sender's address. These equate to the envelope addresses used in the SMTP
protocol. Postfix uses these to deliver or return the mail, just as a postman would do
for a letter. The end users usually never see the email envelope addresses. They are just used
in the SMTP delivery protocol.

On the inside of a postal envelope, there's a letter. This equates to the body of the
email message. Written on the letter, it might begin with "Dear Mom" and end with "Love Seth".
These are equivalent to the To: and From: headers in an email. Just as the postman never uses
what's contained on the letter for mail routing, Postfix never uses the To: and From: headers for
mail routing.

The 'formail" program modifies the content of the mail message body headers, such as the To: and From: lines.

Using my original example, we only modified the From: field, and not the To: field. So, the To: field
still contained "recipient@domain.com" rather than "faxnumber@domain.com". The pipe through the "sendmail -f"
program delivered it to faxnumber@domain.com because that's what the envelope address contained.

Apparently that FAX progam examines the message body headers to determine where to send the FAX, in particular
the To: header. So that's why it worked when you changed formail to modify the To: field in addition to the From: field.

I'm glad that this particular situation works for you. But be aware that in using the "-A" option to formail, the
message will have 2 To: lines. Normally you'd want the "-i" or "-I" options instead of "-A".

--
Greg











  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 21h59.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,13352 seconds with 15 queries