local network - postfix - MUA - mailx

Local network
No registered domain
No IP fixe
The router connected to internet

  1. Set a domain name for the local network : my_example.com
  2. Set a A record for the domain
  3. Set a MX record for the mail server for the domain

Postfix is configured at minima as “Postfix on a local network” documentation
At this first step, postfix is configured to not send mails outside the local network.
Mailbox users are centralized on the mail server.

From a computer ( not the mail server ) I make a test to see if postfix is running at minima.
If by chance I forgot the mail server address, I can always obtain it by the usual command :

dig -t MX my_example.com which return :

~> dig -t MX my_example.com

; <<>> DiG 9.9.9-P1 <<>> -t MX my_example.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 54941
;; flags: qr aa rd ra ad; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

; EDNS: version: 0, flags:; udp: 4096
;my_example.com. IN MX

my_example.com. 0 IN MX 1 my_mail.my_example.com.

;; Query time: 0 msec
;; WHEN: Sun Jun 17 18:15:01 CEST 2018
;; MSG SIZE rcvd: 85

telnet mailserver.my_example.com 25
220 my_example.com ESMTP
ehlo localhost
mail from:some_user
250 OK
rcpt to:another_user
2580 OK
354 .................
this is a test
250 OK : queued as A7CCEF2900C
221 bye
Connection closed by foreign host.

Using telnet I give the address and the port because telnet know nothing about what I plain to do.

My question now :
If I use mailx, it seems that I need also to give the smtp adress as in :

mailx -vvv \
  -s "Subject: mailx send mail smtp shortname to another_user" \
  **-S smtp= \**
  -r "some_user" \
  another_user <<< "This is a test"

even with user@domain :

mailx -vvv \
  -s "Subject: mailx send mail smtp fullname to another_user@my_example.com" \
  **-S smtp= \**
  -r "some_user@my_example.com" \
  another_user@my_example.com <<< "This is a test"

If not, the mail is not sent.

The same apply if I send mail on the computer wher postfix is running.
Is it a mandatory parameter that must be given to mailx ?

Any help is welcome.

The use of an MX record is typically for contacting a remote server – the destination server, not a local server.

When using an MUA, you want to connect to your known local server. You typically would not follow the MX record for this. In large organization, it is typical to use one server for incoming mail and another server for outbound mail. The MX record would be set to the server for incoming mail. But an MUA would be configured to connect to the server for outbound mail.

Have you tried adding

set smtp=

to your “.mailrc” file?

I am not using mailx for sending mail, so I’ve never tried that. But it probably does what you want.

Ok. Noted

I understand that it is mandatory to give the full address when one send mail outside (or use aliases in postfix configuration).

Yes of course it works.
And using the command line it works too.

My question is rather ‘Is it mandatory to tell where is postfix’ for local delivery?
Or in another manner : Is there a way that any user on the local network can send mail to colleague without knowing the mail server address or fqdn name.
And I want all mails reside on the local mail server.

Thank you for any more comments.

PS : I am using mailx to test my server mail configuration.

I’m not really a “postfix” person. I’m using “sendmail” here. But I suppose it is probably the same.

Traditionally, the system administrator takes care for those details. By default, “mailx” sends the mail locally (on the one system). The system administrator would set up the mail software (“sendmail” or “postfix”) to forward that mail to the designated local mail server system.

That way, an ordinary user does not have to do anything. The system admin has taken care of it.

These days, the ordinary user is also the system administrator. And in that case, he does need to know how to set things up.

I always use mail -s test karl </dev/null for testing local mail. There is the nice /etc/sysconfig/postfix which has POSTFIX_LOCALDOMAINS=

Comma separated list of host-/domainnames for which postfix
should accept mail for.
localhost and the own hostname is the default if POSTFIX_LOCALDOMAINS
is set empty.
POSTFIX_LOCALDOMAINS=“$myhostname, $mydomain, localhost.$mydomain”
if you want to use postfix internal variable substitutes or
POSTFIX_LOCALDOMAINS=“example.com, host.example.com, localhost.example.com

A weekend to find this :
Use of SRV Records for Locating Email Submission/Access Services : http://tools.ietf.org/html/rfc6186
Providing-email-client-autoconfiguration-information : http://web.archive.org/web/20120828065248/http://moens.ch/2012/05/31/providing-email-client-autoconfiguration-information

Seems that only thunderbird can do it on linux.
I have tried and it is not so auto configure because it does not find the smtp server by itself. It finds only the domain name from the user email address but don’t tell the fqdn of the mail server.

So one must use configuration files ( In my case. )

Thank you very much everybody for helping.