1

I want to send mail to an outside Office 365 account with the same domain I have for local accounts.

When I try to send mail to this address outside, Postfix rejects it with error "Account not available". So, I want Postfix to send mail to outside account for same domain, if that account is not present locally.

For example I have two email address abc@example.com and xyz@example.com.

  • abc@example.com is present in local server
  • xyz@example.com is an account on Office 365 external mailserver.

Now, I want to send mail to xyz@example.com from Postfix from any local account. The domain example.com is added to relay_domains also, but Postfix still rejects mail with error "recipient not present".

  • Could you give a more detailed explanation? Or maybe illustrate what you want with a couple of examples (e.g. I have a local account bob with an email address of bob@mydomain, and I want to send mail to alice@herdomain). – iwaseatenbyagrue Mar 4 '17 at 8:48
1

As you already have example.com as a local domain configured in either mydestination or virtual_alias_domains you can't achieve this by also adding it to relay_domains.

Instead, you should add a transport(5) map that can override delivery rules defined by the default transport:nexthop used by mydestination, virtual_alias_domains etc.

DESCRIPTION

The optional transport(5) table specifies a mapping from email addresses to message delivery transports and next-hop destinations. Message delivery transports such as local or smtp are defined in the master.cf file, and next-hop destinations are typically hosts or domain names. The table is searched by the trivial-rewrite(8) daemon.

This mapping overrides the default transport:nexthop selection that is built into Postfix.

Add transport_maps to your /etc/postfix/main.cf:

transport_maps = hash:/etc/postfix/transport

And then add to /etc/postfix/transport:

xyz@example.com    smtp:example-com.mail.protection.outlook.com
@example.com       :
*                  :

(Remember to postmap /etc/postfix/transport as you are using hash, Berkeley DB lookup table.)

This will use default transport rules for all @example.com and anything else (*) leaving other delivery configuration as is, but forward all email to xyz@example.com to Office 365 via SMTP: the default pattern for Office 365 MX record for companies is <domain>.mail.protection.outlook.com.


Using transport_maps is a global solution that will work with any external SMTP server. In a specific scenario, where a) the external account is on Office 365 and b) domain is configured on Postfix virtual_alias_domains it could also be possible to add a virtual alias redirecting all mail to Office 365 user's initial domain (tenant) address, xyz@example.com xyz@contoso.onmicrosoft.com.

  • I reformatted your question a little to increase readability and added another Office 365 specific solution (while I'd still prefer transport_maps). I'm glad this worked for you! Could you accept my answer, please? – Esa Jokinen Apr 19 '17 at 12:16
0

add it to your relay_domains & setup a transport map

more details give more details

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.