Postfix email address recipient

Hi All,
I’m new to postfix. I planning to setup a mail server on ubuntu server 20.04 LTS.
I follow this guide: https://www.linuxbabe.com/mail-server/setup-basic-postfix-mail-sever-ubuntu

Everything is working well, I managed to send and receive mail.
But one thing strange is when I send mail to my gmail account, it show the recipient email address with [email protected] instead of [email protected].
Why will this happen? What configuration am I missed and what should I check?

The From: domain name is determined by the myorigin parameter in Postfix.

linuxbabe@mail:~$ postconf myorigin
myorigin = /etc/mailname
linuxbabe@mail:~$ cat /etc/mailname
linuxbabe.com

Thanks for your reply, but the method I tried still same.
Default in /etc/postfix/main.cf
myorigin = /etc/mailname (the result is same)
I tried:
myorigin = mydomain,com (the result still same)

My /etc/mailname already is mydomain,com.

But there is weird if I use echo “testmail” | sendmail anotheruser@gmail,com
The result From: is correct which is ubuntuuser@mydomain,com.

(Sorry i use comma instead of dot because of restriction of new users)

This means your Postfix configuration is correct.

But the address still display as @mail.mydomain.com?

You said earlier that “The result From: is correct which is [email protected]”.

By default, Postfix allows you to use any domain name in the From: address. If you don’t specify a From: address in your email, then Postfix will use @mydomain.com.

The From: address will be displayed as @mail.mydomain.com when you explicitly set it as the From: address.

I means if I use → echo “testmail” | sendmail anotheruser@gmail,com this command, the result is @mydomain.com

But if I use → mail anotheruse@gmail,com this command, the result is @mail.mydomain.com.

so it correct or wrong?

This is correct.

By default, the mail command uses the OS hostname in the FROM: address. You can set the From: address like below.

mail -a FROM:[email protected] [email protected]

or you can change the OS hostname to mydomain .com.

sudo hostnamectl set-hostname mydomain .com

In Postfix main.cf file, you should set

myhostname = mail.mydomain .com