4

I know that you can change the from address in *nix mail by specifying command-line options. However, is there a way to set it globally, so that it is respected by forwarding?

I tried modifying the $REPLYTO environment variable, but this did not help.

Background

I have set up my Raspbian mail to forward by configuring /etc/aliases. However, for external email recipients, the sender is [email protected], where pi is the Linux login name. I want to find a way to specify the username manually, to match my email account, [email protected].

My exim4 configuration is specified here. N.B. there is an option to specify the sender domain ("Visible domain name for local users: bar.com"), but not a way to specify the username for each account.

4
  • Could you do this on your mail client?
    – user2267
    Oct 28, 2014 at 18:22
  • @barrycarter I'm not sure what you mean. There's no mail client involved, really.
    – Sparhawk
    Oct 28, 2014 at 23:31
  • How are you sending email then? Even if you're using /usr/ucb/Mail, that's still a client. These are emails going outbound from your server to someone else, right?
    – user2267
    Oct 29, 2014 at 0:13
  • Ah okay. I guess we're interpreting the word "client" differently. I'm not sure what /usr/ucb/Mail is, but I think I'm using exim4. Emails are sent by the server internally to local mail, and also forwarded externally, as per the second link.
    – Sparhawk
    Oct 29, 2014 at 0:18

1 Answer 1

3

It sounds like you want Exim's address rewriting.

In the rewriting section of your Exim config file, you will probably want something along the lines of this:

[email protected] [email protected] Ffr

You may need to adjust the flags ("Ffr") to the specific behavior you want.

More generally, see: http://www.exim.org/exim-html-current/doc/html/spec_html/ch-address_rewriting.html

Raspbian

Specifically, in Raspbian, edit /etc/exim4/exim4.conf.template, adding the following in the REWRITE CONFIGURATION section.

[email protected] [email protected] Ffr

If you prefer all outgoing email to be from [email protected], regardless of original sender, use this line instead.

* [email protected] Ffr

Next, run sudo update-exim4.conf, then check to make sure it worked with exim -brw [email protected]. This should print out a list of the headers after the rewrite rules have been applied.

3
  • Works perfectly. Thank you! I've taken the liberty of adding information specific to Raspbian, as per the original question. Cheers!
    – Sparhawk
    May 6, 2016 at 10:29
  • Hmmm… is there a way to also change the "Real name" of the sender? At the moment, I'm getting automated emails from root <[email protected]>. I'd like to change the root part.
    – Sparhawk
    May 9, 2016 at 12:02
  • Thanks for that. I'll try it when I have a moment. Thanks again for the great answer!
    – Sparhawk
    May 12, 2016 at 2:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .