On Thu, Feb 24, 2011 at 12:18:36AM -0500, Robert Citek wrote:
> Got this to work on another machine:
> 
> date | mail -s "Test message" [email protected] -- -r [email protected]
> 
> More elegant solutions welcome.

If you just want a command-line solution, you can use mutt.

  $ date | mutt -s "Test message" -e 'set [email protected]' 
[email protected]

or if you want to set the name also and not just the email address

  $ date | mutt -s "Test message" -e 'unset use_from' \
      -e 'my_hdr From: "Robert Citek" <[email protected]>' \
      [email protected]

and if you also want to sent the envelope from (so bounces go to the
person who you want to appear to have sent the message rather than the
actual sender (root))

  $ date | mutt -s "Test message" -e 'unset use_from' \
      -e 'my_hdr From: "Robert Citek" <[email protected]>' \
      -e 'set use_envelope_from' [email protected]

> 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
> >
> 

-- 
David Dooling
http://www.politigenomics.com/

-- 
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