改变“来自:” Unix中的地址“邮件” [英] Change the "From:" address in Unix "mail"
问题描述
使用邮件TO_ADDR
从Unix命令行发送邮件导致来自 $ USER @ $ HOSTNAME
的电子邮件。有没有办法改变由 mail
插入的From:地址?
Sending a message from the Unix command line using mail TO_ADDR
results in an email from $USER@$HOSTNAME
. Is there a way to change the "From:" address inserted by mail
?
为了纪录,在Ubuntu上使用GNU Mailutils 1.1 / 1.2(但是我已经看到与Fedora和RHEL相同的行为)。
For the record, I'm using GNU Mailutils 1.1/1.2 on Ubuntu (but I've seen the same behavior with Fedora and RHEL).
$ mail -s Testing chris@example.org
Cc:
From: foo@bar.org
Testing
.
Subject: Testing
To: <chris@example.org>
X-Mailer: mail (GNU Mailutils 1.1)
Message-Id: <E1KdTJj-00025z-RK@localhost>
From: <chris@localhost>
Date: Wed, 10 Sep 2008 13:17:23 -0400
From: foo@bar.org
Testing
From:foo@bar.org行是邮件正文的一部分,不是标题的一部分。
The "From: foo@bar.org" line is part of the message body, not part of the header.
推荐答案
在我的邮件版本(Debian linux 4.0)中,以下选项用于控制源/回复地址
In my version of mail ( Debian linux 4.0 ) the following options work for controlling the source / reply addresses
- -a 开关,要应用其他标题,请在命令行上提供将被附加到传出邮件头的From:标题
- $ REPLYTO 环境变量指定了一个Reply-To:header
- the -a switch, for additional headers to apply, supplying a From: header on the command line that will be appended to the outgoing mail header
- the $REPLYTO environment variable specifies a Reply-To: header
所以以下序列
export REPLYTO=cms-replies@example.com
mail -aFrom:cms-sends@example.com -s 'Testing'
在我的邮件客户端中,结果是来自cms-sending @ example的邮件。 com,任何回复将默认为cms-replies@example.com
The result, in my mail clients, is a mail from cms-sends@example.com, which any replies to will default to cms-replies@example.com
注意: Mac OS用户:您没有-a,但您确实有 $ REPLYTO
NB: Mac OS users: you don't have -a , but you do have $REPLYTO
这篇关于改变“来自:” Unix中的地址“邮件”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!