Change Default Form Root When Sending Email From Mail or Mailx
In order to change the default sender name when sending an email using the mail or mailx command, you can follow these steps. This will allow you to replace the default “root” with your desired name. Please note that these instructions are typically applicable to Unix-like systems such as Linux.
-
Change the Full Name:
To change the full name associated with your user account, you can use the
chfn(change finger) command. Open your terminal and run the following command, replacing"Your Full Name"with the name you want to use as the sender:1chfn -f "Your Full Name"For example:
1chfn -f "John Doe"This will update the full name associated with your user account.
-
Configure Email Client:
If you are using
mailormailxto send emails from the command line, you can configure it to use your updated full name when sending emails. Unfortunately,mailandmailxdon’t provide built-in options for changing the sender’s name. Instead, they typically use the system’s default settings. However, you can work around this by using the-roption to specify the “From” address when sending emails.Here’s how you can send an email with your updated full name as the sender using
mail:1echo "This is the body of the email" | mail -s "Subject" -r "Your Full Name <your-email@example.com>" recipient@example.comReplace
"Your Full Name"with your updated full name,"your-email@example.com"with your email address, andrecipient@example.comwith the recipient’s email address.For example:
1echo "Hello there!" | mail -s "Greetings" -r "John Doe <john@example.com>" recipient@example.comThis will send an email with “John Doe” as the sender’s name.
By following these steps, you can change the sender’s name when sending emails from the command line using mail or mailx, and it will display your desired name instead of the default “root.”