euglug.org

[Eug-lug] Email from root

작성자

카테고리:



Garl GrigsbyTue Apr 11 08:57:22 PDT 2006

Patrick R. Wade wrote:
> Garl Grigsby wrote:
>
> Are you using Sendmail?  Some MTAs (notably sSMTP) support a 
> reverse-aliases file.  Googlemancy suggests Sendmail may do this with 
> the genericstable, but i haven't used one on my Sendmail setups.
I finally figured out the correct incantation to get most of 
genericstable working lastnight. The real killer is that it only works 
if your message is sent with no FROM: designation. Like this:

    echo "Test message" | sendmail user at example.com

When you do that you get something that looks like this:

<snip>
Received: from srv1.mylocaldomain.loc (localhost.localdomain [127.0.0.1])
	by srv1.mylocaldomain.loc (8.13.1/8.13.1) with ESMTP id xxx
	for <remoteuser at example.net>; Mon, 10 Apr 2006 16:57:16 -0700
Received: (from root at localhost)
	by srv1.mylocaldomain.loc (8.13.1/8.13.1/Submit) id xxx
	for remoteuser at example.net; Mon, 10 Apr 2006 16:57:16 -0700
Date: Mon, 10 Apr 2006 16:57:16 -0700
From: admin at myrealdomain.com
Message-Id: <200604102357.xxx at srv1.mylocaldomain.loc>
Bcc:

Test message


So you can still see where it originated from, but anybody responding to 
it gets a real email address. Now I just need to figure out how to get a 
subject to the message... and a few other niceties.
> As to clients and command lines, nail (a command-line mail client that 
> can do MIME) supports a -r option to specify From.  As you're running 
> jobs as root, you could also do
Cool. That's what I was looking for, and kind of expected to find in a 
command line client. Google wasn't much help though... I'll have to look 
into this.
>
> # su user -c 'fortune `# or other commands` |
> mail -s "example message `date +%s`" badd_karma at comcast.net'
>
> (I.e., the command inside the 'quotes' is executed as "user").
> (And `# this` or $(# this) is the best i've come up with for bash 
> in-line comments).

Doh! I should have thought of using su... Damn that was dumb.