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.

  1. 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:

    1
    
    chfn -f "Your Full Name"

    For example:

    1
    
    chfn -f "John Doe"

    This will update the full name associated with your user account.

  2. Configure Email Client:

    If you are using mail or mailx to send emails from the command line, you can configure it to use your updated full name when sending emails. Unfortunately, mail and mailx don’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 -r option 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:

    1
    
    echo "This is the body of the email" | mail -s "Subject" -r "Your Full Name <[email protected]>" [email protected]

    Replace "Your Full Name" with your updated full name, "[email protected]" with your email address, and [email protected] with the recipient’s email address.

    For example:

    1
    
    echo "Hello there!" | mail -s "Greetings" -r "John Doe <[email protected]>" [email protected]

    This 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.”

0%