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@example.com 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 firstname.lastname@example.org comes from external through Exchange to Linux parser: |/home/user/programname # command "mail external" does not work! It sends to external@linuxmachine" external: email@example.com
If I comment out the line
mail external sends a mail to
firstname.lastname@example.org (which arrives), but incoming mail to
email@example.com is not send through the pipe. So, just the other way round.
What do I have to enter in
/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).
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: 6DFE02003AD: to=<firstname.lastname@example.org>, 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 <20150619084527.6DFE02003AD@linuxmachine.example.com> [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
Jun 19 16:07:31 linuxmachine postfix/smtp: B562720039C: to=<email@example.com>, 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 <20150619140728.B359620039E@linuxmachine.example.com> [InternalId=162971] Queued mail for delivery)