How Do You Change The “From” Address in an Email Sent via the Mail Command on Linux?

Problem scenario
You want Linux to send out an email with a alias email address in the "From" field. You are using the mail command on a Linux server. You want to customize the "from" address in the emails that you send. What do you do to choose your own "from" email address (e.g., in the email that is sent out?


You need to have mailx installed. If you are using a Red Had derivative, use this command: sudo yum -y install mailx

Use this:

echo "payLoad of Message" | mail -s "placeSubjectHere" -r

-replace "payload of Message" with the message you want to send
-replace "placeSubjectHere" with the subject of your email
-replace "" with the email address that you want the email to appear to be from
-replace "" with the destination email address

Leave a comment

Your email address will not be published. Required fields are marked *