How can I change the sender's name or e-mail address (From:
header) used by mutt
?
Normally, mutt sets the From:
header based on the from
configuration variable you set in ~/.muttrc
:
set from="Fubar <foo@bar>"
If this is not set, mutt
uses the EMAIL
environment variable by default. In which case, you can get away with calling mutt like this on the command line (as opposed to how you showed it in your comment):
EMAIL="foo@bar" mutt -s '$MailSubject' -c "abc@def"
However, if you want to be able to edit the From:
header while composing, you need to configure mutt
to allow you to edit headers first. This involves adding the following line in your ~/.muttrc
:
set edit_headers=yes
After that, next time you open up mutt and are composing an E-mail, your chosen text editor will pop up containing the headers as well, so you can edit them. This includes the From:
header.
~/.muttrc
(i.e. /home/$USERNAME/.muttrc
). You edit it with a text editor. If its not there, you create it. I wouldn't call it shell scripting, its just opening an editor, and writing a line in a file ;) –
Overmuch set edit_headers=yes
you can press the edit-from
shortcut (default: ESC f) to edit the from field. –
Chalybite echo set from="Fubar <[email protected]>" > temprc
and then use it: mutt -s "my subject" -F testrc [email protected]
–
Repository set use_envelope_from = yes
in .muttrc finally worked for me. 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. –
Tallia If you just want to change it once, you can specify the 'from' header in command line, eg:
mutt -e 'my_hdr From:[email protected]'
my_hdr
is mutt's command of providing custom header value.
One last word, don't be evil!
echo "I love you body" | mutt -a "/tmp/file.zip" -s "ZIP" -c [email protected] -e 'my_hdr From:[email protected]' -- [email protected]
–
Parcae hostname
. Changing the hostname
on aws is easy, I think on other systems, it should be similar. –
Snicker before you send the email you can press <ESC> f
(Escape followed by f) to change the From:
Address.
Constraint: This only works if you use mutt in curses mode and do not wan't to script it or if you want to change the address permanent. Then the other solutions are way better!
from
was wrong (I almost never use mutt). Saved my bacon, thanks! –
Patric One special case for this is if you have used a construction like the following in your ~/.muttrc:
# Reset From email to default
send-hook . "my_hdr From: Real Name <[email protected]>"
This send-hook will override either of these:
mutt -e "set [email protected]"
mutt -e "my_hdr From: Other Name <[email protected]>"
Your emails will still go out with the header:
From: Real Name <[email protected]>
In this case, the only command line solution I've found is actually overriding the send-hook itself:
mutt -e "send-hook . \"my_hdr From: Other Name <[email protected]>\""
For a one time change you can do this:
export EMAIL='[email protected]'; mutt -s "Elvis is dead" [email protected]
nano
the file and append that one liner at the bottom of the file - or did you put other code around it? –
Unworldly EMAIL='[email protected]' mutt ...
is sufficient (no export
, no ;
). There is no need to export the EMAIL
environment variable permanently. The syntax I show sets the environment variable for a single program invocation. –
Unlawful Step 1: Locate Muttrc which in case of Oracle Linux 7.6 could be found in /etc Step 2: Open the file in vi editor to add the below entries viz. vi /etc/Muttrc Step 3: Contents to be added or/and uncommented
set from = "[email protected]" set realname = "Realname of the user"
Step4: Save the file and exit. Also attempt sending an email with the syntax that follows,
echo "$Body of the email" | mutt -a "$name_of_the_attachment" -s $subject_line_of_the_email" -- [email protected]
100% Working!
To send HTML contents in the body of the mail on the go with Sender and Recipient mail address in single line, you may try the below,
export EMAIL="[email protected]" && mutt -e "my_hdr Content-Type: text/html" -s "Test Mail" "[email protected]" < body_html.html
File: body_html.html
<HTML>
<HEAD> Test Mail </HEAD>
<BODY>
<p>This is a <strong><span style="color: #ff0000;">test mail!</span></strong></p>
</BODY>
</HTML>
Note: Tested in RHEL, CentOS, Ubuntu.
set [email protected]
in ~/.muttrc
–
Funerary © 2022 - 2024 — McMap. All rights reserved.