My probelm in short:

I Have a local mail server (postfix and dovecot and using self-assigned SSL, openssl) on ubuntu server 18.04, i can login from another pc in same network fine (only get warning about self-assigned ssl).

But when i try to send an email (to same user or another user) i see the mail in sent folder. but nothing in inbox. here is my /var/log/mail.log output:

May 25 13:44:17 tsun postfix/submission/smtpd[19418]: Anonymous TLS connection established from unknown[]: TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
May 25 13:44:17 tsun postfix/submission/smtpd[19418]: BBA4C802F5: client=unknown[], sasl_method=PLAIN, sasl_username=veelst
May 25 13:44:17 tsun postfix/cleanup[19425]: BBA4C802F5: message-id=<1c36cd2d-de87-5c32-d053-847623cde2bd@tsun.net>
May 25 13:44:17 tsun postfix/qmgr[19411]: BBA4C802F5: from=<veelst@tsun.net>, size=584, nrcpt=1 (queue active)
May 25 13:44:17 tsun postfix/smtp[19426]: BBA4C802F5: to=<veelst@tsun.net>, relay=none, delay=0.06, delays=0.05/0.01/0/0, dsn=5.4.6, status=bounced (mail for tsun.net loops back to myself)
May 25 13:44:17 tsun postfix/cleanup[19425]: D3AE1802F7: message-id=<20200525134417.D3AE1802F7@mail.tsun.net>
May 25 13:44:17 tsun postfix/submission/smtpd[19418]: disconnect from unknown[] ehlo=2 starttls=1 auth=1 mail=1 rcpt=1 data=1 quit=1 commands=8
May 25 13:44:17 tsun postfix/bounce[19427]: BBA4C802F5: sender non-delivery notification: D3AE1802F7
May 25 13:44:17 tsun postfix/qmgr[19411]: D3AE1802F7: from=<>, size=2425, nrcpt=1 (queue active)
May 25 13:44:17 tsun postfix/qmgr[19411]: BBA4C802F5: removed
May 25 13:44:17 tsun postfix/smtp[19426]: D3AE1802F7: to=<veelst@tsun.net>, relay=none, delay=0.04, delays=0.04/0/0/0, dsn=5.4.6, status=bounced (mail for tsun.net loops back to myself)
May 25 13:44:17 tsun postfix/qmgr[19411]: D3AE1802F7: removed
May 25 13:44:18 tsun dovecot: imap(veelst)<19277><Nqj5HnmmNMzAqAcR>: Connection closed (IDLE running for 0.001 + waiting input for 0.002 secs, 0.001 in locks, 2 B in + 10 B out, state=wait-input) in=906 out=301$
May 25 13:44:18 tsun dovecot: imap-login: Login: user=<veelst>, method=PLAIN, rip=, lip=, mpid=19429, TLS, session=</PPpLHmmhM3AqAcR>

In details:

I have a local mail server running Ubuntu Server 18.04, with the ipadress

Output of hostnamectl:

veelst@tsun:/var/mail$ hostnamectl 
   Static hostname: tsun
  Operating System: Ubuntu 18.04.1 LTS
            Kernel: Linux 4.15.0-101-generic
      Architecture: x86-64

Have postfix and dovecot:

postconf mail_version
mail_version = 3.3.0
dovecot --version (a3d0e1171)

on another machine i have BIND9 DNS server installed with the following zone pointing for the mailserver:

$ttl 38400
tsun.net.   IN  SOA thome.local. admin.tsun.net. (
            38400 )
tsun.net.   IN  NS  thome.local.
mail.tsun.net. 3600 IN A
tsun.net.      3600 IN MX  0 mail.tsun.net.
tsun.net.      3600 IN TXT "v=spf1 mx ~all"
tsun.net.   IN  A

as i said above, i can login fine using my pc on same network using thunderbird. also porst are accesable just fine from my pc, output of sudo nmap mail.tsun.net command:

Starting Nmap 7.80 ( https://nmap.org ) at 2020-05-25 13:34 +03
Nmap scan report for mail.tsun.net (
Host is up (0.00074s latency).
rDNS record for msun
Not shown: 991 closed ports
22/tcp  open  ssh
25/tcp  open  smtp
80/tcp  open  http
110/tcp open  pop3
143/tcp open  imap
465/tcp open  smtps
587/tcp open  submission
993/tcp open  imaps
995/tcp open  pop3s

Nmap done: 1 IP address (1 host up) scanned in 4.04 seconds

someother useful info about my setup:

dovecot -n:

# (a3d0e1171): /etc/dovecot/dovecot.conf
# OS: Linux 4.15.0-101-generic x86_64 Ubuntu 18.04.1 LTS 
# Hostname: tsun
auth_mechanisms = plain login
mail_location = mbox:~/mail:INBOX=/var/mail/%u
mail_privileged_group = mail
namespace inbox {
  inbox = yes
  location = 
  mailbox Drafts {
    auto = create
    special_use = \Drafts
  mailbox Junk {
    auto = create
    special_use = \Junk
  mailbox Sent {
    special_use = \Sent
  mailbox "Sent Messages" {
    special_use = \Sent
  mailbox Trash {
    auto = create
    special_use = \Trash
  prefix = 
passdb {
  driver = pam
protocols = imap pop3
service auth {
  unix_listener /var/spool/postfix/private/auth {
    group = postfix
    mode = 0660
    user = postfix
service lmtp {
  unix_listener /var/spool/postfix/private/dovecot-lmtp {
    group = postfix
    mode = 0600
    user = postfix
ssl_cert = </var/www/cert/certificate.pem
ssl_key = # hidden, use -P to show it
ssl_min_protocol = TLSv1.2
ssl_prefer_server_ciphers = yes
userdb {
  driver = passwd

postconf -n:

alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
compatibility_level = 2
inet_interfaces = all
inet_protocols = all
mailbox_size_limit = 0
mailbox_transport = lmtp:unix:private/dovecot-lmtp
message_size_limit = 52428800
mydestination = $myhostname, localhost.tsun.net, localhost
myhostname = mail.tsun.net
mynetworks = [::ffff:]/104 [::1]/128
myorigin = /etc/mailname
readme_directory = no
recipient_delimiter = +
relayhost =
smtp_tls_loglevel = 1
smtp_tls_mandatory_protocols = !SSLv2, !SSLv3, !TLSv1, !TLSv1.1
smtp_tls_protocols = !SSLv2, !SSLv3, !TLSv1, !TLSv1.1
smtp_tls_security_level = may
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
smtpd_tls_cert_file = /var/www/cert/certificate.pem
smtpd_tls_key_file = /var/www/cert/key.pem
smtpd_tls_loglevel = 1
smtpd_tls_mandatory_protocols = !SSLv2, !SSLv3, !TLSv1, !TLSv1.1
smtpd_tls_protocols = !SSLv2, !SSLv3, !TLSv1, !TLSv1.1
smtpd_tls_security_level = may
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtpd_use_tls = yes
smtputf8_enable = no

Also i used this commands to creat my ssl

$openssl genrsa -out key.pem 2048
$openssl req -new -sha256 -key key.pem -out csr.csr
$sudo openssl req -x509 -sha256 -days 365 -key key.pem -in csr.csr -out certificate.pem
$openssl req -in csr.csr -text -noout | grep -i "Signature.*SHA256" && echo "All is well" || echo "This certificate will stop working in 2017! You must update OpenSSL to generate a widely-compatible certificate"

(i got "All is well" output)

After solved my problem. i got new error in log:

[private/dovecot-lmtp]: Connection refused

fixed it by adding lmtp to protocols in /etc/dovecot/dovecot.conf:

protocols = imap pop3 lmtp

this fixed the connection refused error.

Then i got new error that user is not found. had to fix it by going to /etc/dovecot/conf.d/10-auth.conf and uncomment the line:

auth_username_format = %n

now i can send and recive mail from same network just fine!


Postfix tells you exactly why:

status=bounced (mail for tsun.net loops back to myself)

Try to add tsun.net to the mydestination line in your /etc/postfix/main.cf. The line where you tell it it should be there for the domain "localhost.tsun.net" and "localhost". Maybe a typo?

Then restart your Postfix deamon:

/etc/init.d/postfix restart
  • 1
    Oh My, thank you so much! i knew it was such a silly mistake from me. – Ve3lst May 25 '20 at 15:23

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.