0

I have server where I want to set up a mail server to let me receive and send email from my domain. I'm currently having a problem where while I am can not receive mails. Sending emails works perfect.

I'm going off of this script, which shows how to configure a mail server using Postfix, Dovecot, and using Postgresql as the backend (https://gist.github.com/solusipse/7ed8e1da104baaee3f05).

/etc/postfix/main.cf:

relay_domains =
virtual_alias_maps = proxy:pgsql:/etc/postfix/virtual_alias_maps.cf
virtual_mailbox_domains = proxy:pgsql:/etc/postfix/virtual_mailbox_domains.cf
virtual_mailbox_maps = proxy:pgsql:/etc/postfix/virtual_mailbox_maps.cf
virtual_mailbox_base = /home/vmail
virtual_mailbox_limit = 512000000
virtual_minimum_uid = 5000
virtual_transport = virtual
virtual_uid_maps = static:5000
virtual_gid_maps = static:5000
local_transport = virtual
local_recipient_maps = 
transport_maps = hash:/etc/postfix/transport

smtpd_sasl_auth_enable = yes
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
smtpd_sasl_security_options = noanonymous
smtpd_sasl_tls_security_options = 
smtpd_tls_auth_only = yes
smtpd_tls_cert_file = /etc/ssl/private/server.crt
smtpd_tls_key_file = /etc/ssl/private/server.key
smtpd_sasl_local_domain = 
broken_sasl_auth_clients = yes
smtpd_tls_loglevel = 1
html_directory = /usr/share/doc/postfix/html
queue_directory = /var/spool/postfix
mydestination = localhost

/etc/dovecot/dovecot.conf:

protocols = imap
auth_mechanisms = plain
passdb {
    driver = sql
    args = /etc/dovecot/dovecot-sql.conf
}
userdb {
    driver = sql
    args = /etc/dovecot/dovecot-sql.conf
}
service auth {
    unix_listener /var/spool/postfix/private/auth {
    group = postfix
    mode = 0660
    user = postfix
    }
    user = root
}
mail_home = /home/vmail/%d/%u
mail_location = maildir:~
ssl_cert = </etc/ssl/private/server.crt
ssl_key = </etc/ssl/private/server.key

/var/logs/mail.log:

Apr 17 19:46:18 v22015072919626549 postfix/smtpd[8837]: connect from ***
Apr 17 19:46:18 v22015072919626549 postfix/smtpd[8837]: 62D6A3E0DC9: client=***
Apr 17 19:46:18 v22015072919626549 postfix/cleanup[8843]: 62D6A3E0DC9: message-id=***
Apr 17 19:46:18 v22015072919626549 postfix/smtpd[8837]: disconnect from ***
Apr 17 19:46:18 v22015072919626549 postfix/qmgr[9001]: 62D6A3E0DC9: from=<***>, size=1160, nrcpt=1 (queue active)
Apr 17 19:46:18 v22015072919626549 postfix/virtual[8844]: 62D6A3E0DC9: to=<***>, relay=virtual, delay=0.05, delays=0.01/0.01/0/0.02, dsn=2.0.0, status=sent (delivered to maildir)
Apr 17 19:46:18 v22015072919626549 postfix/qmgr[9001]: 62D6A3E0DC9: removed
3
  • 1
    surely you get an error message in the mailbox you're sending from? - this is the all important piece of information you know!
    – Sum1sAdmin
    Apr 15, 2016 at 17:02
  • @Rob-d I get no error message.
    – Viseo
    Apr 16, 2016 at 11:24
  • Have you checked things like MX record, firewall, etc.?
    – Hang
    Apr 16, 2016 at 22:37

2 Answers 2

1

Apr 17 19:46:18 v22015072919626549 postfix/virtual[8844]: 62D6A3E0DC9: to=<***>, relay=virtual, delay=0.05, delays=0.01/0.01/0/0.02, dsn=2.0.0, status=sent (delivered to maildir)

So Postfix is delivering the mail somewhere, but we don't yet know where.

I am can not receive mails. Sending emails works perfect.

So are you sure Postfix delivers mail where Dovecot is looking?

The e-mail does get stored somewhere; the log excerpt plainly says so. According to the man page on the Postfix web site, virtual(8) constructs the mailbox pathname as $virtual_mailbox_base/$virtual_mailbox_maps(recipient) "where recipient is the full recipient address.". virtual_mailbox_base comes from postfix.cf and in your configuration is set to /home/vmail, and your virtual_mailbox_maps setting looks reasonably valid as well (and if that was where the problem was, you'd probably be seeing Postfix complaining about it).

That is mirrored by Dovecot's configuration mail_home = /home/vmail/%d/%u. But in Dovecot, you are also setting mail_location = maildir:~.

Based on VirtualUsers/Home and MailLocation both on the Dovecot Wiki, it looks like this means that Dovecot is looking for "qmail-style" (also known as Maildir) cur, new and tmp directly under /home/vmail/something/something. Is that where your Postfix virtual mailbox map is configured to deliver the emails for the recipients?

You should be double-checking that the two configurations are in sync. I'm guessing they aren't, and that this is causing the two pieces of software -- which really have next to nothing to do with each other -- to work with different maildir locations. That would explain why both claim that everything is fine, but that they see different views of reality.

It's possible that turning on dont_remove may help you diagnose this, by causing Postfix to leave mail spool files on disk after the final delivery completes. (Mail spool files are normally deleted after successful delivery.)

0

Have you tried telnetting directly to your server on port 25 from another box? One of the most common mistakes is to have iptables block incoming tcp/25. If this gets rejected, you just need to allow incoming tcp/25 through iptables.

1
  • 1
    Yes this is working. Please see my log file
    – Viseo
    Apr 17, 2016 at 17:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .