Score:0

Unable to send email locally using Postfix relay host

fr flag

I have two ubuntu servers 22.04 in the same network 172.16.0.0/24. One is setup as a webserver and the other as a mailserver using mailcow.

For starters my objective is to send an email notification when ever the server has been updated with an security update.

I installed postfix and mailx and configured it to the best of my knowledge.

I am unable to receive the test email using command line echo "this is a test email." | mailx -r someone@mydomain.com -s hello karl@mydomain.com when sending it from my webserver. When using telnet I’m able to send from my webserver and receive from my mailserver.

Below is from the log file from the webserver and the postfix main.cf file configuration I currently have setup.

Your help will much appreciated.

mail.log

Oct  6 08:45:25 cit-serv1 postfix/pickup[126772]: 86AAFFE040F: uid=0 from<karl@mydomain.com>
Oct  6 08:45:25 cit-serv1 postfix/cleanup[127005]: 86AAFFE040F: message-id=<20221006124525.86AAFFE040F@mydomain.com>
Oct  6 08:45:25 cit-serv1 postfix/qmgr[126773]: 86AAFFE040F: from=<karl@mydomain.com>, size=405, nrcpt=1 (queue active)
Oct  6 08:45:25 cit-serv1 postfix/local[127007]: 86AAFFE040F: to=<karl@mydomain.com>, relay=local, delay=0.07, delays=0.05/0/0/0.03, dsn=2.0.0, status=sent (delivered to mailbox)
Oct  6 08:45:25 cit-serv1 postfix/qmgr[126773]: 86AAFFE040F: removed

postfix main.cf

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 3.6 on
# fresh installs.
compatibility_level = 3.6
# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_tls_security_level=may

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 = mydomain.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = $myhostname, mail.mydomain.com, localhost.localdomain, localhost
relayhost = [mail.mydomain.com]:587
mynetworks = 127.0.0.0/8 172.16.0.0/24
mailbox_size_limit = 0
recipient_delimiter = +
#inet_interfaces = all
inet_interfaces = loopback-only
inet_protocols = all

# outbound relay configurations
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_security_level = may
header_size_limit = 4096000
Score:0
jp flag

The email is being delivered locally and not being sent to the relayhost. You should find your test messages in /var/spool/mail/karl on the webserver.

You are including mydomain.com as part of the mydestination setting.

myhostname = mydomain.com
mydestination = $myhostname, mail.mydomain.com, localhost.localdomain, localhost

Quoting from postfix documentation

The mydestination parameter specifies what domains this machine will deliver locally, instead of forwarding to another machine

The mail.log is also indicating local delivery with hints like relay=local and delivered to mailbox.

user3596617 avatar
fr flag
I was able to send a test email by commenting out mydestination
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.