0

I have read all of the threads and can't figure out what is the problem. I can send emails. I can receive emails from my localhost and my other email names of the same domain, but I cannot receive emails from external emails like Gmail etc.

Everything is sent and authenticated, but nothing is received.

Here are the configs for Dovecot and Postfix:

sudo doveconf -n
# 2.3.14 (cee3cbc0d): /etc/dovecot/dovecot.conf
# Pigeonhole version 0.5.14 (1b5c82b2)
# OS: Linux 4.15.0-29-generic x86_64 Ubuntu 18.04.5 LTS
# Hostname: nameofthehost
auth_mechanisms = plain login
dict {
  sqlquota = mysql:/etc/dovecot/dovecot-dict-sql.conf.ext
}
first_valid_uid = 5000
last_valid_uid = 5000
mail_gid = vmail
mail_location = mbox:~/mail:INBOX=/var/mail/%u
mail_plugins = quota
mail_privileged_group = vmail
mail_uid = vmail
managesieve_notify_capability = mailto
managesieve_sieve_capability = fileinto reject envelope encoded-character vacation subaddress comparator-i;ascii-numeric relational regex imap4flags copy include variables body enotify environment mailbox date index ihave duplicate mime foreverypart extracttext imapsieve vnd.dovecot.imapsieve
namespace inbox {
  inbox = yes
  location =
  mailbox Drafts {
    special_use = \Drafts
  }
  mailbox Junk {
    special_use = \Junk
  }
  mailbox Sent {
    special_use = \Sent
  }
  mailbox "Sent Messages" {
    special_use = \Sent
  }
  mailbox Spam {
    auto = subscribe
    special_use = \Junk
  }
  mailbox Trash {
    special_use = \Trash
  }
  prefix =
}
passdb {
  args = /etc/dovecot/dovecot-sql.conf.ext
  driver = sql
}
plugin {
  imapsieve_mailbox1_before = file:/var/mail/vmail/sieve/global/report-spam.sieve
  imapsieve_mailbox1_causes = COPY
  imapsieve_mailbox1_name = Spam
  imapsieve_mailbox2_before = file:/var/mail/vmail/sieve/global/report-ham.sieve
  imapsieve_mailbox2_causes = COPY
  imapsieve_mailbox2_from = Spam
  imapsieve_mailbox2_name = *
  quota = dict:User quota::proxy::sqlquota
  quota_exceeded_message = Quota exceeded, please contact your system administrator.
  quota_grace = 10%%
  quota_rule = *:storage=5GB
  quota_rule2 = Trash:storage=+100M
  quota_warning = storage=100%% quota-warning 100 %u
  quota_warning2 = storage=95%% quota-warning 95 %u
  quota_warning3 = storage=90%% quota-warning 90 %u
  quota_warning4 = storage=85%% quota-warning 85 %u
  sieve = file:/var/mail/vmail/sieve/%d/%n/scripts;active=/var/mail/vmail/sieve/%d/%n/active-script.sieve
  sieve_before = /var/mail/vmail/sieve/global/spam-global.sieve
  sieve_global_extensions = +vnd.dovecot.pipe
  sieve_pipe_bin_dir = /usr/bin
  sieve_plugins = sieve_imapsieve sieve_extprograms
}
protocols = " imap lmtp sieve pop3"
service auth-worker {
  user = vmail
}
service auth {
  unix_listener /var/spool/postfix/private/auth {
    group = postfix
    mode = 0666
    user = postfix
  }
  unix_listener auth-userdb {
    group = vmail
    mode = 0600
    user = vmail
  }
}
service dict {
  unix_listener dict {
    group = vmail
    mode = 0660
    user = vmail
  }
}
service lmtp {
  unix_listener /var/spool/postfix/private/dovecot-lmtp {
    group = postfix
    mode = 0600
    user = postfix
  }
}
service managesieve-login {
  inet_listener sieve {
    port = 4190
  }
}
service managesieve {
  process_limit = 1024
}
service quota-warning {
  executable = script /usr/local/bin/quota-warning.sh
  unix_listener quota-warning {
    group = vmail
    mode = 0660
    user = vmail
  }
  user = vmail
}
ssl_cert = </etc/letsencrypt/live/mydomain.com/fullchain.pem
ssl_cipher_list = EECDH+AES:EDH+AES+aRSA
ssl_dh = # hidden, use -P to show it
ssl_key = # hidden, use -P to show it
ssl_prefer_server_ciphers = yes
userdb {
  args = /etc/dovecot/dovecot-sql.conf.ext
  driver = sql
}
protocol lmtp {
  mail_plugins = quota sieve
  postmaster_address = postmaster@mydomain.com
}
protocol imap {
  mail_plugins = quota imap_quota imap_sieve
}
postconf -n
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
broken_sasl_auth_clients = yes
compatibility_level = 2
inet_interfaces = all
inet_protocols = all
mailbox_size_limit = 0
milter_default_action = accept
milter_mail_macros = i {mail_addr} {client_addr} {client_name} {auth_authen}
milter_protocol = 6
mydestination = localhost.$mydomain, localhost, $mydomain
myhostname = nameofthehost
myorigin = /etc/mailname
non_smtpd_milters = inet:127.0.0.1:11332
readme_directory = no
recipient_delimiter = +
relayhost =
smtp_tls_note_starttls_offer = yes
smtp_tls_security_level = may
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
smtpd_milters = inet:127.0.0.1:11332
smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain =
smtpd_sasl_path = private/auth
smtpd_sasl_security_options = noanonymous
smtpd_sasl_type = dovecot
smtpd_tls_cert_file = /etc/letsencrypt/live/mydomain.com/fullchain.pem
smtpd_tls_key_file = /etc/letsencrypt/live/mydomain.com/privkey.pem
smtpd_tls_loglevel = 1
smtpd_tls_received_header = yes
smtpd_tls_security_level = may
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtpd_use_tls = no
virtual_alias_maps = mysql:/etc/postfix/sql/mysql_virtual_alias_maps.cf, mysql:/etc/postfix/sql/mysql_virtual_alias_domain_maps.cf, mysql:/etc/postfix/sql/mysql_virtual_alias_domain_catchall_maps.cf
virtual_mailbox_domains = mysql:/etc/postfix/sql/mysql_virtual_domains_maps.cf
virtual_mailbox_maps = mysql:/etc/postfix/sql/mysql_virtual_mailbox_maps.cf, mysql:/etc/postfix/sql/mysql_virtual_alias_domain_mailbox_maps.cf
virtual_transport = lmtp:unix:private/dovecot-lmtp

How can I debug this? And how can I start receiving emails?

UPDATE:

When sending the mail from Gmail I am getting that it is delivered:

Message ID  <CALJ3QLOrZD5GhaaaFiXO5xZp+=sjSa1+PF5w=DBgozHB5qEu3A@mail.gmail.com>
Created on: 18 May 2023 at 11:16 (Delivered after 0 seconds)

Here is the mail.log file:

May 18 11:15:39 3b15 dovecot: imap-login: Login: user=<contact@mydomain.com>, method=PLAIN, rip=::1, lip=::1, mpid=4319, secured, session=<8kXxaPP7Yt4AAAAAAAAAAAAAAAAAAAAB>
May 18 11:15:39 3b15 dovecot: imap(contact@mydomain.com)<4319><8kXxaPP7Yt4AAAAAAAAAAAAAAAAAAAAB>: Logged out in=90 out=972 deleted=0 expunged=0 trashed=0 hdr_count=0 hdr_bytes=0 body_count=0 body_bytes=0
May 18 11:16:41 3b15 dovecot: imap-login: Login: user=<contact@mydomain.com>, method=PLAIN, rip=::1, lip=::1, mpid=4331, secured, session=<hkGZbPP7dN4AAAAAAAAAAAAAAAAAAAAB>
May 18 11:16:41 3b15 dovecot: imap(contact@mydomain.com)<4331><hkGZbPP7dN4AAAAAAAAAAAAAAAAAAAAB>: Logged out in=90 out=972 deleted=0 expunged=0 trashed=0 hdr_count=0 hdr_bytes=0 body_count=0 body_bytes=0
May 18 11:17:23 3b15 postfix/anvil[4241]: statistics: max connection rate 1/60s for (smtps:212.83.8.79) at May 18 11:14:03
May 18 11:17:23 3b15 postfix/anvil[4241]: statistics: max connection count 1 for (smtps:212.83.8.79) at May 18 11:14:03
May 18 11:17:23 3b15 postfix/anvil[4241]: statistics: max cache size 1 at May 18 11:14:03
May 18 11:17:39 3b15 dovecot: imap-login: Login: user=<contact@mydomain.com>, method=PLAIN, rip=::1, lip=::1, mpid=4402, secured, session=<OsMWcPP7it4AAAAAAAAAAAAAAAAAAAAB>
May 18 11:17:39 3b15 dovecot: imap(contact@mydomain.com)<4402><OsMWcPP7it4AAAAAAAAAAAAAAAAAAAAB>: Logged out in=90 out=972 deleted=0 expunged=0 trashed=0 hdr_count=0 hdr_bytes=0 body_count=0 body_bytes=0
May 18 11:18:01 3b15 postfix/pickup[4122]: 8D50342261: uid=33 from=<www-data>
May 18 11:18:01 3b15 postfix/cleanup[4411]: 8D50342261: message-id=<20230518081801.8D50342261@som.time4vps.cloud>
May 18 11:18:01 3b15 postfix/qmgr[4123]: 8D50342261: from=<www-data@3som.time4vps.cloud>, size=745, nrcpt=1 (queue active)
May 18 11:18:01 3b15 postfix/smtp[4413]: 8D50342261: to=<www-data@3som.time4vps.cloud>, orig_to=<www-data>, relay=none, delay=0.09, delays=0.06/0.03/0.01/0, dsn=5.4.6, status=bounced (mail for som.time4vps.cloud loops back to myself)
May 18 11:18:01 3b15 postfix/cleanup[4411]: A04B742262: message-id=<20230518081801.A04B742262@som.time4vps.cloud>
May 18 11:18:01 3b15 postfix/qmgr[4123]: A04B742262: from=<>, size=3524, nrcpt=1 (queue active)
May 18 11:18:01 3b15 postfix/bounce[4414]: 8D50342261: sender non-delivery notification: A04B742262
May 18 11:18:01 3b15 postfix/qmgr[4123]: 8D50342261: removed
May 18 11:18:01 3b15 postfix/smtp[4413]: A04B742262: to=<www-data@som.time4vps.cloud>, relay=none, delay=0.01, delays=0.01/0/0/0, dsn=5.4.6, status=bounced (mail for som.time4vps.cloud loops back to myself)
May 18 11:18:01 3b15 postfix/qmgr[4123]: A04B742262: removed

I tried to change mydestination = localhost.$mydomain, localhost, mail.$mydomain, $mydomain but still no luck.

Don40
  • 103
  • 1
  • 5
  • What error message do you get if you attempt to send mail from e.g. gmail? – vidarlo May 18 '23 at 08:13
  • @vidarlo There are no error messages. All seems fine. I am trying to look in the logs and debug something, but there are no error messages at all. – Don40 May 18 '23 at 08:15
  • So the messages are delivered to your server? What does the logs show? – vidarlo May 18 '23 at 08:16
  • @vidarlo I updated the log again, I think it shows more information now. – Don40 May 18 '23 at 08:39
  • @vidarlo after making several more tests, and sending several more emails, I don't think that the emails are being logged. I am only getting the `imap-login` lines, does this mean that the emails are not getting to my server? – Don40 May 18 '23 at 09:10
  • Do you have a valid e-mail address I can send an e-mail to so that I can se what happens to an inbound message? – vidarlo May 18 '23 at 09:51
  • @vidarlo Yes, you can send an email here: contact@ognyanyankov.com – Don40 May 18 '23 at 10:02
  • Added it as an answer due to formatting. In short you're not accepting incoming connections on port 25. – vidarlo May 18 '23 at 10:07

1 Answers1

2

I sent an message to the address specified in comments. Here's the logs from my outgoing MTA:

May 18 12:04:09 eli postfix/smtp[19064]: connect to _dc-mx.e81f8d7bf4a5.ognyanyankov.com[2606:4700:3033::ac43:c709]:25: Connection timed out
May 18 12:04:39 eli postfix/smtp[19064]: connect to _dc-mx.e81f8d7bf4a5.ognyanyankov.com[104.21.44.110]:25: Connection timed out
May 18 12:05:09 eli postfix/smtp[19064]: connect to _dc-mx.e81f8d7bf4a5.ognyanyankov.com[172.67.199.9]:25: Connection timed out
May 18 12:05:39 eli postfix/smtp[19064]: 20A222E015B: to=<contact@ognyanyankov.com>, relay=none, delay=120, delays=0.18/0.03/120/0, dsn=4.4.1, status=deferred (connect to _dc-mx.e81f8d7bf4a5.ognyanyankov.com[2606:4700:3032::6815:2c6e]:25: Connection timed out)

Something is blocking connections. This also ensures that mail can't be delivered.

vidarlo
  • 6,654
  • 2
  • 18
  • 31
  • Thank you, so should I do something to the DNS settings, or I should look for what is blocking port 25 – Don40 May 18 '23 at 10:09
  • You should look into why your e-mail servers are not reachable on port 25. – vidarlo May 18 '23 at 10:19
  • So far when I try `telnet mail.ognyanyankov.com 25` I am not getting anything. But when I try `telnet mail.ognyanyankov.com 443` I am getting `Connected to mail.ognyanyankov.com` – Don40 May 18 '23 at 10:47
  • Why `mail.ognyanyankov.com`? Your MX is `_dc-mx.e81f8d7bf4a5.ognyanyankov.com`. And port 443 is used for HTTPS, not SMTP. Based on your response the best tip is probably to hire someone who knows how e-mail works. Additionally, you should ***not*** run a Ubuntu 16.04 machine for such roles: 16.04 is End of Life, and does not receive security patches! – vidarlo May 18 '23 at 10:50
  • This is a very old project that I have to fix so this is the reason I am doing this. The project uses CloudFlare and the MX record there is `mail.ognyanyankov.com` so this is the reason I was looking into that subdomain. Thank you for all the help. I will try to figure out what is blocking port 25. – Don40 May 18 '23 at 10:54
  • Well, a hint is what CF does to DNS records. Your DNS records points to CF. Do CF handle e-mail? I'm not spending more time on this question; if the hints are not enough, hire someone that can do this. You clearly can't. – vidarlo May 18 '23 at 10:57
  • Okay, so the final hint fixed it all. It was actually CF blocking everything. When I disabled the proxy of the `mail.ognyanyankov.com` as started working again. Thank you very much for the help. – Don40 May 18 '23 at 11:03