Linux mail command from address
The mail
command in Linux allows you to send emails from the command line. By default, the From
address is set to the username of the current user. However, you can specify a different From
address using the -s
or --sender
option.
Here is an example:
mail -s "Your Name" -f "[email protected]" [email protected]
This will send an email to [email protected]
with the subject "Your Name" and the From
address set to [email protected]
.
You can also use the -a
or --from
option to specify the From
address:
mail -a "[email protected]" [email protected]
Note that the From
address must be a valid email address.
If you want to specify a different From
address for all future emails sent using the mail
command, you can set the MAILFROM
environment variable:
export MAILFROM="[email protected]"
This will set the default From
address for all future emails sent using the mail
command.
Alternatively, you can also use the sendmail
command, which is a more powerful and flexible email client than the mail
command. With sendmail
, you can specify the From
address using the -f
option:
sendmail -f "[email protected]" [email protected]
Note that the sendmail
command is not installed by default on all Linux systems, so you may need to install it separately.