2

I've been fiddling with main.cf file for a long time but still couldn't find why. I've set up an email server with this tutorial Email with Postfix, Dovecot and MariaDB on CentOS 7

This is the part about postfix:

myhostname = server.example.com
mydestination = localhost, localhost.localdomain
mynetworks = 127.0.0.0/8
inet_interfaces = all
message_size_limit = 30720000
virtual_alias_domains =
virtual_alias_maps = proxy:mysql:/etc/postfix/mysql-virtual_forwardings.cf, mysql:/etc/postfix/mysql-virtual_email2email.cf
virtual_mailbox_domains = proxy:mysql:/etc/postfix/mysql-virtual_domains.cf
virtual_mailbox_maps = proxy:mysql:/etc/postfix/mysql-virtual_mailboxes.cf
virtual_mailbox_base = /home/vmail
virtual_uid_maps = static:5000
virtual_gid_maps = static:5000
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes
broken_sasl_auth_clients = yes
smtpd_sasl_authenticated_header = yes
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
smtpd_use_tls = yes
smtpd_tls_cert_file = /etc/pki/dovecot/certs/dovecot.pem
smtpd_tls_key_file = /etc/pki/dovecot/private/dovecot.pem
virtual_create_maildirsize = yes
virtual_maildir_extended = yes
proxy_read_maps = $local_recipient_maps $mydestination $virtual_alias_maps $virtual_alias_domains $virtual_mailbox_maps $virtual_mailbox_domains $relay_recipient_maps $relay_domains $canonical_maps $sender_canonical_maps $recipient_canonical_maps $relocated_maps $transport_maps $mynetworks $virtual_mailbox_limit_maps
virtual_transport = dovecot
dovecot_destination_recipient_limit = 1

Now within my server, I could send emails from user1@example.com to user2@example.com, I could receive emails from user@gmail.com, but I couldn't send an email to user@gmail.com. I got an error: Relay access denied. Is there anything I should change?


EDIT:

This is from /var/log/maillog

NOQUEUE: reject: RCPT from unknown[(Server's IP)]: 454 4.7.1 <user@gmail.com>: Relay access denied; from=<user1@example.com> to=<user@gmail.com> proto=SMTP
  • Please edit your question and post relevant maillog LINES when rejection happened. – masegaloeh Aug 7 '15 at 13:07
  • @masegaloeh updated – Searene Aug 7 '15 at 13:34
3

Notice this part in main.cf:

smtpd_recipient_restrictions = permit_mynetworks ...

So smtpd only permits IP addresses from mynetworks to relay emails.

What you need to do is to add your IP to mynetworks. For example, if your IP address is 192.168.1.123, change the parameter to

mynetworks = 127.0.0.0/8 192.168.1.123

Then you can send emails successfully.

  • More detail/explanation would improve your answer – Dave M Aug 7 '15 at 18:17
  • It worked after trying many postfix configurations, but does anybody knows why Mozilla Thunderbird works without this setting? – iwxfer May 6 '17 at 23:04
  • 2
    maybe because you have set up smtp authentication within thunderbird? – roothahn Jun 3 '17 at 16:47

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.