3

I send email from my server like this:

echo "This is the body of the email" | mail -s "This is the subject line" user@example.com

Noted that I replace user@example.com with a real email address. And it works. Just I need to know, where this nickname comes from?

enter image description here

I use ubuntu 14.04 on the server and I want to know how can I change that name?

2 Answers 2

5

Don't use mail, there are better command-line MUAs, such as mailx (package bsd-mailx) or mutt.

mailx will do what you want with the -r flag:

echo Test. | mailx -r "Joe Sender <sender@domain.com>" -s Test recipient@domain.com

You can likewise specify a display name for the recipient, by the way.

The nickname shown in for instance gmail.com comes from the part of the From field that is outside <sender@domain.com>, so in this example it would be Joe Sender.

2
  • Great .. thank you .. upvote. Just in reality my problem is this. if you have some free time, please take a look at it.
    – stack
    Dec 23, 2017 at 14:48
  • This does not work. When I send an email to my google mail account, it only shows the address sender@domain.com but not the "Joe Sender"...
    – bzero
    Aug 27, 2020 at 8:43
2

Using mail, you can set the username using the proper syntax, such as echo "Test" | mail -a "From: Someone <someone@example.com>" other@example.com.

1
  • 1
    Thanks! This is the only solution that works from all mentioned solutions...
    – bzero
    Aug 27, 2020 at 8:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.