2

I'm trying to setup postfix on a Linux machine (Debian 8 with Postfix 2.11). But I have some troubles getting /etc/aliases to work correctly.

The setup is as follows: A MS Exchange server is the actual mail server - it recieves mails and sends mails, and it is in the same local network as the Linux machine. Postfix on the Linux machine does use this Exchange machine as a relayhost to send mails. This works, so for example mail [email protected] arrives.

Now on the Exchange there exists a mail address that is forwarded to the Linux machine. In /etc/aliases I have an alias for this that is a pipe to a program, because the mails going to this address contain some code that should be parsed by the program.

In order to make this work, I have to alter the mydestination setting in main.cf. But as soon as I do so, Postfix stops relaying mails when their alias of /etc/aliases is used. Only typing the long name works. This is my configuration (I started from zero):

# main.cf
# our internet domain name (the thing after the "@")
mydomain = example.com

# this is the critical setting
mydestination = linuxmachine, 192.168.1.200, $mydomain

# IP of Exchange
relayhost = 192.168.1.100

# so that addresses look correct
masquerade_domains = $mydomain

# in order to make the pipe programm work with correct permission
default_privs = myuser

With this configuration the piping of incoming mail works, but sending mail to an alias does not work:

# /etc/alias
# none of the entries are actual users on the linux machine!

#works when mail to [email protected] comes from external through Exchange to Linux
parser: |/home/user/programname 

# command "mail external" does not work! It sends to external@linuxmachine"
external: [email protected] 

If I comment out the line mydestination in main.cf then mail external sends a mail to [email protected] (which arrives), but incoming mail to [email protected] is not send through the pipe. So, just the other way round.

What do I have to enter in main.cf or /etc/aliases to be able to send mails from my Linux machine using short names and at the same time be able to receive mail to a pipe? All I want is that a special address is parsed on the linux machine and that linux users are able to send mails to selected addresses using short names as a "luxory" (instead of having to type full email addresses).

Update: postconf -n output:

config_directory = /etc/postfix
default_privs = myuser
masquerade_domains = $mydomain
mydestination = linuxmachine, 192.168.1.200, $mydomain
mydomain = example.com
relayhost = 192.168.1.100

Update 2: Output from /var/log/mail.info when doing mail external (mail to alias) with mydestination set like above:

Jun 19 10:45:27 linuxmachine postfix/smtp[26425]: 6DFE02003AD: to=<[email protected]>, orig_to=<external>, relay=192.168.1.100[192.168.1.100]:25, delay=0.24, delays=0/0/0/0.24, dsn=2.6.0, status=sent (250 2.6.0 <[email protected]> [InternalId=162319] Queued mail for delivery)

Update 3, after changing mydestination according to the proposed answer, the mail.info log shows the following line when doing mail external:

Jun 19 16:07:31 linuxmachine postfix/smtp[2299]: B562720039C: to=<[email protected]>, orig_to=<external>, relay=192.168.1.100[192.168.1.100]:25, delay=2.6, delays=0/0/0/2.5, dsn=2.6.0, status=sent (250 2.6.0 <[email protected]> [InternalId=162971] Queued mail for delivery)
3
  • Can you post the output of postconf -n? Also, can you provide maillog when postfix fail to send to [email protected]?
    – masegaloeh
    Jun 18, 2015 at 16:38
  • @masegaloeh I added postconf -n (with mydestination set). Will add log later.
    – Foo Bar
    Jun 19, 2015 at 8:42
  • @masegaloeh Added the log
    – Foo Bar
    Jun 19, 2015 at 8:49

1 Answer 1

3

The obvious solution is put $myhostname or linuxmachine.example.com in mydestination parameter.

explanation

Before the config modification, here the background event after you send email via mail external

  • Postfix receives email via pickup service.
  • Because the recipient doesn't have domain parts and (by default) parameter append_at_myorigin has value yes, then postfix will rewrite recipient address to [email protected] (you can see it in mail.log above)
  • By default, parameter mydestination has value $myhostname or linuxmachine.example.com, so postfix apply aliasing map in /etc/aliases.
  • Postfix aliased [email protected] to [email protected] and then send it to gmail host

Now after config modification, this is what happens

  • Postfix receives email via pickup service.
  • Because the recipient doesn't have domain parts and (by default) parameter append_at_myorigin has value yes, then postfix will rewrite recipient address to [email protected] (you can see it in mail.log above)
  • Now mydestination doesn't contain $myhostname or linuxmachine.example.com, so postfix won't apply aliasing in /etc/aliases
5
  • I now see to=<[email protected]>, orig_to=<external> in mail.info, but the mail still does not arrive in the external inbox, however. I tested it with several external mail addresses from different e-mail providers (I run newaliases each time, of course).
    – Foo Bar
    Jun 19, 2015 at 10:50
  • When I post a mail to [email protected] via alias internal: [email protected] the mail correctly arrives in the Exchange inbox. But If I then look at the mail header, it has: To: <[email protected] instead of [email protected]. I assume this is the problem why it does not arrive at external servers (Envelope and Mail Headers differ). How do I change this?
    – Foo Bar
    Jun 19, 2015 at 11:03
  • Can you update the question with log after you modified mydestination?
    – masegaloeh
    Jun 19, 2015 at 13:56
  • Updated the question with the mail.info message after changing mydestination and doing mail external.
    – Foo Bar
    Jun 19, 2015 at 14:11
  • Well, mail.log said that postfix successfully relay email to exchange. Please also checks exchange log.
    – masegaloeh
    Jun 19, 2015 at 14:23

You must log in to answer this question.

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