Website on Virtualmin and Email hosted on Office 365

Operating system: Ubuntu
OS version: 20.04

So I have used Virtualmin for years hosting several of my websites.
Lately we need a better email and calendar solution than what IMAP can provide, so have chosen to use MS Office 365 for my main company website email service provider (mainwebsite.com).

I have the DNS MX records and mail setup and its working well with cloudflare.com for mainwebsite.com.

Another part of my company has another domain name (anotherwebsite.com) with basic website.
I want a sales@anotherwebsite.com to forward to my main Office 365 email address my.name@mainwebsite.com.

When I send an email to the sales@anotherwebsite.com which I forward to my.name@mainwebsite.com the server sees it and in the mail.log I see:
Nov 27 09:30:00 hostname postfix/local[152530]: A0FA980478: to=my.name@mainwebsite.com, orig_to=sales@anotherwebsite.com, relay=local, delay=0.03, delays=0.01/0.01/0/0.01, dsn=5.1.1, status=bounced (unknown user: “my.name”)

For the first website (mainwebsite.com) I have the Mail feature disabled (in edit virtual server).
The second website (anotherwebsite.com) Mail is enabled and I use this to forward from this to my first email address (my.name@mainwebsite.com).

I do not have any users setup on mainwebsite.com as there is no email hosted on this server, hence the message from the mail.log as above.
I can see whats happening I think, where the domain part is matching the virtualhost and is trying to be delivered locally on the server, but it needs to be sent out to the internet where it will see the mx record (on cloudflare.dom) and be delivered to my Office 365 account.

I hope you can follow this and there is a solution to push the email out from my server to the internet for the NS/DNS lookup.

Many thanks and regards.
J

In your Virtualmin DNS, edit the records for mainwebsite to reflect the actual DNS records, particularly the MX records for the domain. There is currently a disparity between the Virtualmin DNS records and the actual DNS records for mainwebsite due to which Virtualmin / Postfix is attempting to deliver email for my.name@mainwebsite to localhost instead of Office 365 servers, as you have correctly surmised, @wozie

Virtualmin -> Server Configuration -> DNS Records

Hi,
Thanks for your fast reply.

I have added a MX record now:
mainwebsite.com. 1h IN MX 0 ms-server-details.mail.eo.outlook.com.

When I send to this email: sales@anotherwebsite.com it still shows a bounce in the log with the same error:
Nov 27 11:26:19 hostname postfix/local[152530]: 790CA8094F: to=my.name@mainwebsite.com, orig_to=sales@anotherwebsite.com, relay=local, delay=0.03, delays=0.01/0.01/0/0.01, dsn=5.1.1, status=bounced (unknown user: “my.name”)

Seems still to look on this server for the user on this domain and not looking out. Did I set the TTL too high?

Restart BIND if you don’t want to wait for the records to propagate.

Apologies, I did restart Bind9: “systemctl restart bind9” forgot to add it to the last post.

FYI: I copied the DNS settings for the MX record from my working existing settings on cloudflare to the server as above. However the Priority on Cloudflare is 1 and on my server is Priority 0.

I can confirm I am still seeing the bounce in the mail.log.

That’s strange, it should work the way you want it to after you apply the MX records to Virtualmin’s DNS and restart BIND… :thinking:

Perhaps someone else can suggest an alternate solution?

Yeah, your solution made sense to me to tell it to look elsewhere for the user with the addition of the MX record. Strange it is still looking on the server for the “my.name” user.

Just looking in /etc/postfix/main.cf
$myhostname = mainwebsite.com
mydestination = $myhostname, mainwebsite.com, localhost.co.uk, , localhost

But I have disabled the mail function for the server in the Virtualmin gui - Edit Virtual Server.

Ah, I had assumed (and it is Virtualmin’s recommendation) that hostname be a subdomain such as vps.mainwebsite.com and if it is not then, of course, merely adding a MX will not do the trick in your case.

Hi,

So I added the subdomain: server.mainwebsite.com in the main.cf file.

This sent the email to the Microsoft office 365 server ok now but the O365 server is bouncing the emails back with the following:

Nov 27 12:26:58 hostname postfix/smtp[255935]: 842C28049A: to=sales-anotherwebsite.com@mainwebsite.com, orig_to=sales@anotherwebsite.com, relay=ms-server.mail.eo.outlook.com[104.47.20.36]:25, delay=0.21, delays=0.01/0.02/0.08/0.1, dsn=5.4.1, status=bounced (host ms-server.mail.eo.outlook.com[104.47.20.36] said: 550 5.4.1 Recipient address rejected: Access denied. AS(201806281) [CWLGBR01FT009.eop-gbr01.prod.protection.outlook.com] (in reply to RCPT TO command)

So from this, I can see it is now malforming the to email address to sales-anotherwebsite.com@mainwebsite.com - this is not being recognized by the Office 365 server and bouncing it (the email should be: my.name@mainwebsite.com).

It is also sending emails sent from my system: root@mainwebsite.com to O365 and these are also bouncing.

I have changed back and removed the subdomain “server” from the main.cf file for the meantime.

Thanks for your help

Yay!

Now all you need to do is configure Virtualmin the way the official documentation specifies and all will be well.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.