I had installed and configured dovecot, postfix, and postfixadmin step by step from this tutorial on my server (CentOS6).
I can create virtual mailboxes as well now and can login to roundcubemail, I can also send emails but when I want to send email from other mail systems like gmail, yahoo and etc then I get this error:
This is the mail system at host domain.com.
I'm sorry to have to inform you that your message could not be delivered to one or more recipients. It's attached below.
For further assistance, please send mail to postmaster.
If you do so, please include this problem report. You can delete your own text from the attached returned message.
The mail system
<[email protected]>: unknown user: "admin" Final-Recipient: rfc822; [email protected] Original-Recipient: rfc822;[email protected] Action: failed Status: 5.1.1 Diagnostic-Code: X-Postfix; unknown user: "admin"
This is postfix main.cf
:
# network settings
inet_interfaces = all
mydomain = domain.com
myhostname = mail.domain.com
mynetworks = $config_directory/mynetworks
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
relay_domains = proxy:mysql:/etc/postfix/mysql-relay_domains_maps.cf
And the mynetworks
file:
192.168.0.0/16
10.0.0.0/8
127.0.0.0/8
[::ffff:127.0.0.0]/104
[::1]/128
127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
130.185.0.0/16 # -> my domain ip
And mysql-relay_domains_maps.cf
:
hosts = localhost
user = postfix
password = postfixpassword
dbname = postfix
query = SELECT domain FROM domain WHERE domain='%s' and backupmx = '1'
The error showing up in the logs is the following:
postfix/local[19002]: 38902E0550: to=<[email protected]>, relay=local, delay=0.09, delays=0.06/0.01/0/0.02, dsn=5.1.1, status=bounced (unknown user: "admin")
After reading some posts and I changed mydestination from this
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
to
mydestination = localhost
but after this change, I the error in the logs change to:
postfix/smtp[18844]: D6EEFE0550: to=<[email protected]>, relay=none, delay=0.14, delays=0.05/0.01/0.08/0, dsn=5.4.6, status=bounced (mail for domain.com loops back to myself)
mydestination
parametermydestination = localhost
setting, which is apparently false for a public mailserver. To cite from another answer: This happens when domain.com has an MX record (or, in the absence of an MX, an A record) that points to your Postfix server, but your Postfix server is not configured to accept mail for that domain.relay_domains
, which is by default$mydestination
, that lists the domains that are deliverd locally. You have to insert your domains into the MySQL table there, have you done that?