Got this to work on another machine:

date | mail -s "Test message" [email protected] -- -r [email protected]

More elegant solutions welcome.

Regards,
- Robert

On Thu, Feb 24, 2011 at 12:08 AM, Robert Citek <[email protected]> wrote:
> Hello all,
>
> Anyone know how to modify the From address when using the linux mail command?
>
> I'm wanting to run a cronjob from root that sends out a message as
> originating from a particular user.  However, every test message I've
> tried shows it as coming from root@$hostname.  A google search
> suggested two routes, using -r or using -a and specifying the From:
> header.  Neither of these worked for me:
>
> $ date | mail -r [email protected] -s "Test message" [email protected]
> $ date | mail -a "From: [email protected]" -s "Test message"
> [email protected]
>
> Apparently, my version of mail doesn't have the -r option.  The -a
> options works with every other header but "From:", e.g. "X-foo: bar"
> gets added to the headers of the message.
>
> It would be silly to have to rewrite this relatively simple task in
> perl/php/ruby/python or even raw smtp because of this one missing
> feature in mail.
>
> Still googling but any pointers appreciated.
>
> Regards,
> - Robert
>

-- 
Central West End Linux Users Group (via Google Groups)
Main page: http://www.cwelug.org
To post: [email protected]
To subscribe: [email protected]
To unsubscribe: [email protected]
More options: http://groups.google.com/group/cwelug

Reply via email to