Change sender's address in mutt via console

3.3k views Asked by At

I want to dynamically set the sender's address when using mutt via console (not composing). I checked everything which is described, tried everything from this SO question but nothing works. There is no change at all, no matter what I do. I set

set from="[email protected]"
set edit_headers=yes

in both the /etc/Muttrc and ~/.muttrc, also, I tried all sort of -e commands, like

-e "set [email protected]"
-e 'my_hdr From:[email protected]'
-e "send-hook . 'my_hdr From: Other Name <otheremail\@example.com>'"
having export [email protected]  in front

but I will always receive mails from [email protected]

A typical call looks like this

export EMAIL="[email protected]" && echo | mutt -s "VERSANDTEST" -c "[email protected]"  -e 'my_hdr From:[email protected]' -a /opt/data/YoloDat.txt /opt/data/TroloDat.txt  -- "[email protected]"  < /tmp/mailbody

Any more ideas appreciated

2

There are 2 answers

0
elim On

Use set use_envelope_from = yes in your .muttrc. This adds the -f option when calling sendmail to deliver the mail, forcing it to use the same address for the envelope as for the From: header field.

Setting set edit_headers = yes in .muttrc was not required to use the my_hdr-Flag on the command line.

echo "Test" | mutt -e "my_hdr From:[email protected]" -- [email protected]
0
Rowshi On

This works for me:

export EMAIL="Name <[email protected]>";
echo "Test message body" | mutt -s "Test Subject" -- [email protected];