Null Client Mail Server

Chr asked:

I want to set up a null client mail server, i.e. a mail server that sends e-mails, but does not receive e-mails. I tried multiple guides relying on postfix, checked discussions on this and other sites, and consulted the official postfix website. The server still does not send e-mails. The message submitted via the following line

echo "This is the body of an encrypted email" | mail -s "This is the subject line" [email protected]

where [email protected] is an e-mail address of mine that is not related to that server does not arrive. I already tried checked multiple recipient e-mail addresses. None of them receives a message.

The content of /etc/postfix/main.cf currently is

# Debian specific:  Specifying a file name will cause the first
# line of that file to be used as the name.  The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname

smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no

# appending .domain is the MUA's job.
append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h

readme_directory = no

# See http://www.postfix.org/COMPATIBILITY_README.html -- default to 2 on
# fresh installs.
compatibility_level = 2

# TLS parameters
smtpd_tls_cert_file=/etc/letsencrypt/live/example.com/fullchain.pem
smtpd_tls_key_file=/etc/letsencrypt/live/example.com/privkey.pem
smtpd_tls_security_level=may
smtp_use_tls=yes
smtp_tls_CApath=/etc/ssl/certs
smtp_tls_security_level=may
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = someone.localdomain
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = $mydomain
mydestination =
relayhost = $mydomain
mynetworks = 127.0.0.0/8 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = loopback-only
inet_protocols = ipv4
local_transport = error: local delivery disabled

Instead of example.com I use my actual domain.

On the DNS server, I only set an A record. Do I need a MX record? Do I need to set up a subdomain?

I configured the ufw to allow for postfix traffic: sudo ufw allow Postfix

This Ubuntu 20.04 machine also hosts a nginx web server.

What I would like to do is to send e-mails directly from the server using a shell script. I do not want to connect it to any program outside the server. The setup should be as secure as possible, blocking any incoming e-mails or attacks using the mail ports. I do not have a particular preference for postfix. It is simply the software that most guides use.

My answer:


For some reason you have set

relayhost = $mydomain

This doesn’t make any sense, as you say you are trying to send outbound mail directly to its destination, rather than back to yourself. Even if you were trying to redeliver all mail locally, this wouldn’t be the way to do it.

Just remove this line from your configuration entirely.


View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.