LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   postfix incoming bounce problem (https://www.linuxquestions.org/questions/linux-server-73/postfix-incoming-bounce-problem-828600/)

craseal 08-26-2010 07:59 AM

postfix incoming bounce problem
 
I set up postfix with dovecot and everything works fine (I can send e-mails both locally and from a client), except for incoming mails.

I checked my logs and whenever an email comes in, let's say that it was sent to john@example.com, postfix changes it to john@HOSTNAME.local. The message then of course bounces, because I set to accept messages only for domains that exist on my server.

Something important: I have multiple domains on my server, and I want all of them to be able to send e-mails. That's why I have setup virtual domains in postfix.

Here's my main.cf:
Code:

queue_directory = /var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix

mail_owner = postfix
inet_interfaces = all

mydestination = localhost, /etc/postfix/domains/domains
virtual_maps = hash:/etc/postfix/domains/addresses


unknown_local_recipient_reject_code = 550
mynetworks = 127.0.0.0/8

alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
home_mailbox = Maildir/

debug_peer_level = 2
debugger_command =
    PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
    xxgdb $daemon_directory/$process_name $process_id & sleep 5

sendmail_path = /usr/sbin/sendmail.postfix
newaliases_path = /usr/bin/newaliases.postfix
mailq_path = /usr/bin/mailq.postfix
setgid_group = postdrop
html_directory = no
manpage_directory = /usr/share/man
sample_directory = /usr/share/doc/postfix-2.3.3/samples
readme_directory = /usr/share/doc/postfix-2.3.3/README_FILES

smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes
smtpd_recipient_restrictions = check_policy_service inet:127.0.0.1:9999,
    permit_mynetworks,
    permit_sasl_authenticated,
    reject_non_fqdn_recipient,
    reject_unknown_recipient_domain,
    reject_unauth_destination,
smtpd_sender_restriction = reject_non_fqdn_sender
broken_sasl_auth_clients = yes


jamrock 08-26-2010 10:43 AM

I would recommend reading the following documents:

http://www.postfix.org/BASIC_CONFIGURATION_README.html

http://www.postfix.org/VIRTUAL_READM...irtual_mailbox

It is best to get everything working with a single domain and local users first. Then you can add virtual domains and virtual users.

I think you need to change this.

Quote:

mydestination = localhost, /etc/postfix/domains/domains
Please note the following from the documentation:

Quote:

IMPORTANT: If your machine is a mail server for its entire domain, you must list $mydomain as well.

Example 1: default setting.

/etc/postfix/main.cf:
mydestination = $myhostname localhost.$mydomain localhost

Example 2: domain-wide mail server.

/etc/postfix/main.cf:
mydestination = $myhostname localhost.$mydomain localhost $mydomain

Example 3: host with multiple DNS A records.

/etc/postfix/main.cf:
mydestination = $myhostname localhost.$mydomain localhost
www.$mydomain ftp.$mydomain




Quote:

Notes:

*

Line 2: The virtual_mailbox_domains setting tells Postfix that example.com is a so-called virtual mailbox domain. If you omit this setting then Postfix will reject mail (relay access denied) or will not be able to deliver it (mail for example.com loops back to myself).

NEVER list a virtual MAILBOX domain name as a mydestination domain!

craseal 08-26-2010 02:49 PM

I've changed the mydestination parameter to this setting as you suggested.

But this didn't change anything so I removed virtual_maps = hash:/etc/postfix/domains/addresses and now I can receive mail for my primary domain, but not for any other domain.

So I followed the http://www.postfix.org/VIRTUAL_README.html and set this (let's say example.com is my primary domain -> I set the parameter mydomain to list it as such):
Code:

virtual_alias_domains = example.net, example.org
virtual_alias_maps = hash:/etc/postfix/domains/addresses

The /etc/postfix/domains/addresses file looks like this:
Code:

info@example.net    info
john@example.net    john

info@example.org    info
nelly@example.org    nelly
kate@example.org    kate

I can still receive the e-mail for my main domain, but all e-mail meant for example.net and example.org are redirected to root@hostname.example.com

jamrock 08-26-2010 11:04 PM

What value do you have for myorigin in your main.cf?

Example.com is the local domain, not any of the virtual ones. What happens when you send mail to info@example.com?

What happens when you send mail to info?

Which of the 3 options did you choose for mydestination?

craseal 08-27-2010 06:09 AM

I didn't have a value set for myorigin. Now I've set it to $mydomain, which results in all mails being rerouted to @example.com.

This is my mydestination setting:
Code:

mydestination = $myhostname, localhost.$mydomain, $mydomain, localhost
If I send a message to info@example.com or to info, it's delivered to info@example.com. If I send mail to info@example.net or any other mail at example.net or example.org it's rerouted to root@example.com (

jamrock 08-27-2010 07:38 AM

Take a look at your logs.

cat /var/log/maillog

What does it say about mail that is being sent to info@example.net? It should tell you why the mail is being forwarded to root@example.com.

Did you run the command "postmap /etc/postfix/virtual"? This creates the database from the hash:/etc/postfix/domains/addresses text file. Postfix reads the database in order to know the accounts to which the mail must be forwarded.

Here is some more information on setting up virtual domains.

http://www.postfix.org/virtual.5.html

craseal 08-27-2010 10:19 AM

Yes, I've run the postmap command and then reloaded postfix.

The log is not really helpful (at least not for me):
Code:

Aug 27 18:12:57 mladi postfix/local[7971]: BB74C54EA254: to=<root@example.com>, orig_to=<info@example.net>, relay=local, delay=0.2, delays=0.12/0.05/0/0.03, dsn=2.0.0, status=sent (delivered to maildir)

jamrock 08-27-2010 11:32 AM

I see what you mean. The mails are being forwarded to root without any error messages. I will try to reproduce this over the weekend.

Please post the results of "postconf -n". This will show your Postfix configuration.

On another issue. Did you edit the aliases file to map root to a regular user account?

craseal 08-27-2010 12:05 PM

Here's the result from postconf -n:
Code:

alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
broken_sasl_auth_clients = yes
command_directory = /usr/sbin
config_directory = /etc/postfix
daemon_directory = /usr/libexec/postfix
debug_peer_level = 2
home_mailbox = Maildir/
html_directory = no
inet_interfaces = all
mail_owner = postfix
mailq_path = /usr/bin/mailq.postfix
manpage_directory = /usr/share/man
mydestination = $myhostname, localhost.$mydomain, $mydomain, localhost
mydomain = example.com
mynetworks = 127.0.0.0/8
myorigin = $mydomain
newaliases_path = /usr/bin/newaliases.postfix
queue_directory = /var/spool/postfix
readme_directory = /usr/share/doc/postfix-2.3.3/README_FILES
sample_directory = /usr/share/doc/postfix-2.3.3/samples
sendmail_path = /usr/sbin/sendmail.postfix
setgid_group = postdrop
smtpd_recipient_restrictions = permit_mynetworks,        permit_sasl_authenticated,    reject_unknown_recipient_domain,  reject_unauth_destination,    reject_non_fqdn_recipient
smtpd_sasl_auth_enable = yes
smtpd_sasl_path = private/auth
smtpd_sasl_type = dovecot
unknown_local_recipient_reject_code = 550
virtual_alias_domains = example.net, example.org
virtual_alias_maps = hash:/etc/postfix/domains/addresses

The aliases file is untouched. I checked it and root isn't mapped to anything, there are however a lot of services mapped to root, but no e-mails among them. The only e-mail address mappings I have are in /etc/postfix/domains/addresses.

jamrock 08-29-2010 02:07 PM

Okay then...

Quote:

Yes, I've run the postmap command and then reloaded postfix.
What file did you use with the postmap command?

Quote:

virtual_alias_maps = hash:/etc/postfix/domains/addresses
It appears as if you need to run

postmap /etc/postfix/domains/addresses

This will create a file called /etc/postfix/domains/addresses.db. This is the database that postfix will search. It seems as if /etc/postfix/virtuals is the default file.

If that doesn't work, you can try using a file in the /etc/postfix directory such as /etc/postfix/domain_addresses.

craseal 08-30-2010 06:16 AM

Thank you for your help jamrock, I really apreciate it!

I have run postmap with the file /etc/postfix/domains/addresses, but I guess you're right and it would be easier if I put that file in the postfix directory.

Since I was a bit pressed with time constraints I just set up a google apps account for handling e-mails. I have only about 10 e-mail addresses (for now) that need to be taken care, so I guess this will have to do it until I have enough time to set up postfix properly.

Thanks again for your effort and all the help!


All times are GMT -5. The time now is 01:10 AM.