8

I have a few emails in my mailq which are bounced for a good reason, the email address is wrong. I was wondering if it is possible to modify the address of the recipient on the fly. I can see the directory where the mail deferred are stored and I could probably change something there, but i am wondering if there is a proper way to do this.

Any thought?

momeunier
  • 125
  • 1
  • 1
  • 6

1 Answers1

10

The best way (or the least intrusive way) would be to have an address rewrite for that recipient. From the Postfix Address Rewriting

/etc/postfix/main.cf:
    smtp_generic_maps = hash:/etc/postfix/generic

/etc/postfix/generic:
    his@localdomain.local       hisaccount@hisisp.example

Following this example, you could try:

cd /etc/postfix

Add to the generic file or create it with:

yourbadlyspelledname@destination.com        you_name@destination.com

and build the associated map:

sudo postmap generic

Add to main.cf:

smtp_generic_maps = hash:/etc/postfix/generic

make Postfix load this configuration change:

sudo postfix reload

smtpd will use generic to rewrite the problematic address upon next scan of queue.

dan
  • 168
  • 9
Torian
  • 2,314
  • 18
  • 10
  • 3
    Since smtp_generic_maps is applied to mail *delivery*, there is no need to re-queue the mail. The smtp(8) daemon performs this rewrite. – adaptr Oct 15 '12 at 15:12
  • 2
    Good one, and don't forget to issue `postmap /etc/postfix/generic` after editing `/etc/postfix/generic`. – kasimir Jun 17 '13 at 19:00
  • I integrated the 2 relevant commants from adaptr & kasimir, after successfully testing on an address to change. – dan Nov 09 '18 at 11:43
  • Is there anyway to do this with the config executables `postconf` or `postmap`? – OrangePot Jan 11 '21 at 23:03