Debian Wheezy Postfix/Dovecot - Office 365 smtp relay.

If none of the specific sub-forums seem right for your thread, ask here.
Post Reply
Message
Author
Peppe
Posts: 177
Joined: 2007-01-01 13:16
Location: Sweden , Stockholm

Debian Wheezy Postfix/Dovecot - Office 365 smtp relay.

#1 Post by Peppe »

I'm trying to set up a test enviroment before I put it into production.
This is the model;

Office365 (Internal relay) <--> Debian with one domain
I have finaly got it working apart from this;
When sendning mail from Debian --> Office365 I get the following error;

Code: Select all

failed
Status: 5.1.1
Diagnostic-Code: x-unix; user unknown
This works;
Sendning mail from Office365 --> Debian
Sending and receive to external mail adress work from both Office 365 and Debian.
My postconf;

Code: Select all

 postconf -n
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
config_directory = /etc/postfix
dovecot_destination_recipient_limit = 1
inet_interfaces = all
inet_protocols = all
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
mydestination =
myhostname = myhostname.mydomain.com
mynetworks =
myorigin = /etc/mailname
readme_directory = no
recipient_delimiter = +
relayhost = mydomain.com
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
smtpd_recipient_restrictions = permit_mynetworks , permit_sasl_authenticated , reject_unauth_destination
smtpd_sasl_auth_enable = yes
smtpd_sasl_path = private/auth
smtpd_sasl_type = dovecot
smtpd_tls_auth_only = yes
smtpd_tls_cert_file = /etc/ssl/certs/mailserver.pem
smtpd_tls_key_file = /etc/ssl/private/mailserver.pem
smtpd_tls_security_level = may
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtpd_use_tls = yes
virtual_alias_maps = mysql:/etc/postfix/mysql-virtual-alias-maps.cf
virtual_mailbox_domains = mysql:/etc/postfix/mysql-virtual-mailbox-domains.cf
virtual_mailbox_maps = mysql:/etc/postfix/mysql-virtual-mailbox-maps.cf
virtual_transport = dovecot
I'm guessing that a parameter should be changed so that postfix checks with Office365 it the account exist there.
I have googled a lot over this, and I think that this is the key;

Code: Select all

mydestination = $myhostname, localhost.$mydomain $mydomain

Tried several different combinations, but I get the same NDR as above each time.

Please let me known if you want more information regardning the configuration.
Thanks in advance and for reading.

Regards, Peter
Running Debian Squeeze with xfce4 on a Fujitsu P7120 and a Asus ITX HTPC with Debian Squeeze with xfce4 . Debian just keeps getting better and better .

User avatar
dilberts_left_nut
Administrator
Administrator
Posts: 5464
Joined: 2009-10-05 07:54
Location: enzed
Has thanked: 21 times
Been thanked: 93 times

Re: Debian Wheezy Postfix/Dovecot - Office 365 smtp relay.

#2 Post by dilberts_left_nut »

Hi Peppe - long time since Freesco? :)
Peppe wrote:Office365 (Internal relay) <--> Debian with one domain
Can you elaborate a little?
Office365 & Debian have different domains?
Your local clients collect mail from dovecot & send via postfix?

Can you describe the transaction that generates the error? (client, from, to)
Provide associated mail log entries?

You probably should have at least localhost in mydestination, even if all users are in virtual domains.
AdrianTM wrote:There's no hacker in my grandma...

Peppe
Posts: 177
Joined: 2007-01-01 13:16
Location: Sweden , Stockholm

Re: Debian Wheezy Postfix/Dovecot - Office 365 smtp relay.

#3 Post by Peppe »

Hi Peppe - long time since Freesco? :)
Indeed, haven't been active there for a while, nice to have some old friends in familiar place :D
Office365 & Debian have different domains?
Both resides in the same domain.
The idea is to use Office365 mailservices for some users and postfix/dovecot for other users.
Example;

User1 mailaccount is located at Office365 servers - peter.thylander@example.org

User2 mailaccount is located at my local postfix/dovecot server - r2d2@example.org

Both users need to have the same domainname and I need a Hybridsolution - in other words office365+Postfix/dovecot.

Taken from the log from the serverlog;

Code: Select all

Apr 16 16:13:56 mailserver postfix/cleanup[7695]: 5FE9220C16: message-id=<92e91ac13edd6e8f4bdcd93635150cc0@example.org>
Apr 16 16:13:56 mailserver postfix/qmgr[5475]: 5FE9220C16: from=<r2d2@example.org>, size=543, nrcpt=1 (queue active)
Apr 16 16:13:56 mailserver dovecot: imap(r2d2@example.org): Disconnected: Logged out in=465 out=519
Apr 16 16:13:56 mailserver postfix/pipe[7699]: 5FE9220C16: to=<peter.thylander@example.org>, relay=dovecot, delay=0.46, delays=0.22/0.03/0/0.2, dsn=5.1.1, status=bounced (user unknown)
Apr 16 16:13:56 mailserver postfix/cleanup[7695]: B95A320AFB: message-id=<20150416141356.B95A320AFB@mailserver@example.org>
Apr 16 16:13:56 mailserver postfix/qmgr[5475]: B95A320AFB: from=<>, size=2409, nrcpt=1 (queue active)
Apr 16 16:13:56 mailserver postfix/bounce[7701]: 5FE9220C16: sender non-delivery notification: B95A320AFB
Apr 16 16:13:56 mailserver postfix/qmgr[5475]: 5FE9220C16: removed
Apr 16 16:13:57 mailserver dovecot: lda(r2d2@example.org): msgid=<20150416141356.B95A320AFB@example.org>: saved mail to INBOX
Apr 16 16:13:57 mailserver postfix/pipe[7699]: B95A320AFB: to=<r2d2@example.org>, relay=dovecot, delay=0.32, delays=0.12/0.01/0/0.18, dsn=2.0.0, status=sent (delivered via dovecot service)
Apr 16 16:13:57 mailserver postfix/qmgr[5475]: B95A320AFB: removed
Apr 16 16:13:57 mailserver dovecot: imap-login: Login: user=<r2d2@example.org>, method=PLAIN, rip=::1, lip=::1, mpid=7705, secured, session=<YIETE9gTfQAAAAAAAAAAAAAAAAAAAAAB>
Apr 16 16:13:57 mailserver dovecot: imap(r2d2@example.org): Disconnected: Logged out in=44 out=552
Apr 16 16:13:58 mailserver dovecot: imap-login: Login: user=<r2d2@example.org>, method=PLAIN, rip=::1, lip=::1, mpid=7707, secured, session=<uQ0bE9gTfgAAAAAAAAAAAAAAAAAAAAAB>
Taken from the NDR;

Code: Select all

This is the mail system at host mailserver.example.org

I'm sorry to have to inform you that your message could not
be delivered to one or more recipients. It's attached below.

For further assistance, please send mail to postmaster.

If you do so, please include this problem report. You can
delete your own text from the attached returned message.

                   The mail system

<peter.thylander@example.org>: user unknown
Reporting-MTA: dns; mailserver@example.org
X-Postfix-Queue-ID: 5FE9220C16
X-Postfix-Sender: rfc822; r2d2@example.org
Arrival-Date: Thu, 16 Apr 2015 16:13:56 +0200 (CEST)

Final-Recipient: rfc822; peter.thylander@example.org
Action: failed
Status: 5.1.1
Diagnostic-Code: x-unix; user unknown
Return-Path: <r2d2@example.org>
Received: by mailserver@example.org (Postfix, from userid 33)
	id 5FE9220C16; Thu, 16 Apr 2015 16:13:56 +0200 (CEST)
To: <peter.thylander@example.org>
Subject: test16:13
X-PHP-Originating-Script: 0:main.inc
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8;
 format=flowed
Content-Transfer-Encoding: 7bit
Date: Thu, 16 Apr 2015 16:13:56 +0200
From: r2d2@example.org
Message-ID: <92e91ac13edd6e8f4bdcd93635150cc0@mind-research.nu>
X-Sender: r2d2@example.org
User-Agent: Roundcube Webmail/0.7.2

Hope that this makes it a little bit clearer.......
Running Debian Squeeze with xfce4 on a Fujitsu P7120 and a Asus ITX HTPC with Debian Squeeze with xfce4 . Debian just keeps getting better and better .

User avatar
dilberts_left_nut
Administrator
Administrator
Posts: 5464
Joined: 2009-10-05 07:54
Location: enzed
Has thanked: 21 times
Been thanked: 93 times

Re: Debian Wheezy Postfix/Dovecot - Office 365 smtp relay.

#4 Post by dilberts_left_nut »

Peppe wrote:Both resides in the same domain.
The idea is to use Office365 mailservices for some users and postfix/dovecot for other users.
Example;

User1 mailaccount is located at Office365 servers - peter.thylander@example.org

User2 mailaccount is located at my local postfix/dovecot server - r2d2@example.org

Both users need to have the same domainname and I need a Hybridsolution - in other words office365+Postfix/dovecot.
https://technet.microsoft.com/en-us/lib ... 41%29.aspx
Looks like you will need a small truck to deliver all the licences, and carry away all your cash ;)

If this is what you mean, I think you won't be doing it with Postfix & Dovecot.

If I send a mail to someuser@example.org, my server does an MX lookup for example.org to decide where to send it - what would the reply be?

The two different systems will need different domains, but you could use aliases to make it transparent to users and public.
AdrianTM wrote:There's no hacker in my grandma...

Peppe
Posts: 177
Joined: 2007-01-01 13:16
Location: Sweden , Stockholm

Re: Debian Wheezy Postfix/Dovecot - Office 365 smtp relay.

#5 Post by Peppe »

Ok, let my try to restate what I have done and what I want to do.

I have set up a Debian mailserver with Postfix/Dovecot accordning to this guide;
https://workaround.org/ispmail/wheezy

And I have an Office 365 account set up with an inbound and outbound connection and Internal relay with some help from Office365 support.
I'm using SMTP relay;
https://technet.microsoft.com/en-us/lib ... .150).aspx


Both servers are on the same domain.

Office365 has one account;
peter.thylander@example.org

Debian server has one account;
r2d2@example.org


From Office365 I can;

Send from peter.thylander@example.org --> r2d2@example.org
Send from peter.thylander@example.org --> any other external mail adress

From the Debian server I can:
Send from r2d2@example.org --> any other external mail adress

The only thing I cannot do is this;
Send from r2d2@example.org --> peter.thylander@example.org in other words, sending mail from an account that exists on the Debian server cannot be sent to an account that exists on Office365 but the other way around works.


EDITED;
Maybe the word Hybrid shouldn't have been added in thread by me - something I picked up on the way and might not relevant.

Regards
Running Debian Squeeze with xfce4 on a Fujitsu P7120 and a Asus ITX HTPC with Debian Squeeze with xfce4 . Debian just keeps getting better and better .

User avatar
dilberts_left_nut
Administrator
Administrator
Posts: 5464
Joined: 2009-10-05 07:54
Location: enzed
Has thanked: 21 times
Been thanked: 93 times

Re: Debian Wheezy Postfix/Dovecot - Office 365 smtp relay.

#6 Post by dilberts_left_nut »

Peppe wrote:The only thing I cannot do is this;
Send from r2d2@example.org --> peter.thylander@example.org in other words, sending mail from an account that exists on the Debian server cannot be sent to an account that exists on Office365 but the other way around works.
Because you have told postifix that it is responsible for the example.org domain, but it has no user called peter.thylander.

You could probably change your local domain to local.example.org and set an alias for each "local" example.org address.
AdrianTM wrote:There's no hacker in my grandma...

Peppe
Posts: 177
Joined: 2007-01-01 13:16
Location: Sweden , Stockholm

Re: Debian Wheezy Postfix/Dovecot - Office 365 smtp relay.

#7 Post by Peppe »

You could probably change your local domain to local.example.org and set an alias for each "local" example.org address.
Okay, how do I do that?
I understand how to add local.example.org but I'm unsure where to add alias.

Should I add a ailas for each user on the Office365 enviroment?
The Office365 enviroment is planned to have at the most twenty user, so it isn't a huge job to create a user list.

Regrads
Running Debian Squeeze with xfce4 on a Fujitsu P7120 and a Asus ITX HTPC with Debian Squeeze with xfce4 . Debian just keeps getting better and better .

User avatar
dilberts_left_nut
Administrator
Administrator
Posts: 5464
Joined: 2009-10-05 07:54
Location: enzed
Has thanked: 21 times
Been thanked: 93 times

Re: Debian Wheezy Postfix/Dovecot - Office 365 smtp relay.

#8 Post by dilberts_left_nut »

Peppe wrote:[Okay, how do I do that?
I understand how to add local.example.org but I'm unsure where to add alias.
http://www.postfix.org/postconf.5.html# ... alias_maps
Presumably it can work with mysql, but is probably easier with just a lookup table file.
Should I add a ailas for each user on the Office365 enviroment?
No, add the alias' for your local users.
/etc/postfix/virtualalias: (or such)

Code: Select all

r2d2@example.org r2d2@local.example.org
other@example.org other@local.example.org
The Office365 enviroment is planned to have at the most twenty user, so it isn't a huge job to create a user list.
How many local users?
AdrianTM wrote:There's no hacker in my grandma...

Peppe
Posts: 177
Joined: 2007-01-01 13:16
Location: Sweden , Stockholm

Re: Debian Wheezy Postfix/Dovecot - Office 365 smtp relay.

#9 Post by Peppe »

http://www.postfix.org/postconf.5.html# ... alias_maps
Presumably it can work with mysql, but is probably easier with just a lookup table file.
Ok, when I followed the guide to set up the linux mail server - I added the following tool that uses mysql to add alias;
http://mat.ssdata.dk/

So, I added the following alias;

Code: Select all

r2d2@example.org r2d2@local.example.org
Same error;

Code: Select all

Recipient address rejected: User unknown in virtual mailbox table;
Then I tried something different;

Code: Select all

peter.thylander@local.example.org peter.thylander@local.example.org
Got another error message;

Code: Select all

The domain name in the email address is incorrect. Check the address.
How many local users?
Office365 is planned to have 20 local users
Linux mail server is planned to have up to 200 users

Regards

EDITED:
Project stopped and is going to another direction. We are not going with Office365 - may start another thread in the future.
Thanks for all help!
Regards, Peter
Last edited by Peppe on 2015-06-01 09:03, edited 1 time in total.
Running Debian Squeeze with xfce4 on a Fujitsu P7120 and a Asus ITX HTPC with Debian Squeeze with xfce4 . Debian just keeps getting better and better .

User avatar
dilberts_left_nut
Administrator
Administrator
Posts: 5464
Joined: 2009-10-05 07:54
Location: enzed
Has thanked: 21 times
Been thanked: 93 times

Re: Debian Wheezy Postfix/Dovecot - Office 365 smtp relay.

#10 Post by dilberts_left_nut »

Peppe wrote:So, I added the following alias;

Code: Select all

r2d2@example.org r2d2@local.example.org
Same error;

Code: Select all

Recipient address rejected: User unknown in virtual mailbox table;
Using the same test? (sending FROM r2d2@example.org TO peter.thylander@example.org).
If so it means your postfix still considers 'example.org' to be local and is attempting delivery to the non-existant user peter.thylander, instead of relaying it to the server responsible (office365)
Adding the alias won't affect that, but changing your local domain will.
Then I tried something different;

Code: Select all

peter.thylander@local.example.org peter.thylander@local.example.org
Got another error message;

Code: Select all

The domain name in the email address is incorrect. Check the address.
Where did that error come from?
When doing what?
How many local users?
Office365 is planned to have 20 local users
Linux mail server is planned to have up to 200 users
OK, so you need to decide which server is going to handle the example.org domain and which is going to have the subdomain.
You can't have them both do it (without using the nasty kludge with two Exchanges - which really has nothing to do with SMTP mail delivery and relies on proprietary hackery within the Exchange delivery mechanisms).
I'm not sure how Office365 works with sending mail from a different address than the "real" mailbox name, so their rules may constrain what you can do, but I would lean towards having YOUR server be the one responsible for everybody@example.org and have 20 aliases pointing to 20users@office365.example.org (or such).
AdrianTM wrote:There's no hacker in my grandma...

Post Reply