Mail settings for Microsoft 365 Topic is solved

Need help with the Administration of your Joomla! 4.x site? This is the spot for you.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10
Post Reply
meky86
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Thu Sep 08, 2022 11:31 am

Mail settings for Microsoft 365

Post by meky86 » Thu Sep 08, 2022 11:45 am

how can I set up mail settings for office 365 SMTP with Multi factor authentication!
I tried everything but failed to send even test email!
Last edited by toivo on Thu Dec 01, 2022 10:56 pm, edited 1 time in total.
Reason: mod note: retitled

User avatar
mjparadac
Joomla! Hero
Joomla! Hero
Posts: 2488
Joined: Mon Oct 29, 2012 3:58 pm

Re: Mail settings

Post by mjparadac » Thu Sep 08, 2022 5:12 pm

Hello meky86, welcome to the forum

This thread could help you
viewtopic.php?t=985145

Regards,
Joomla Community Ambassador for A2 Hosting | A2 Hosting - Our speed, your success | https://www.a2hosting.com/joomla-hosting

User avatar
Astrophel
Joomla! Apprentice
Joomla! Apprentice
Posts: 25
Joined: Fri Dec 12, 2008 4:32 am
Location: Ottawa, ON Canada
Contact:

Re: Mail settings

Post by Astrophel » Tue Nov 22, 2022 12:41 am

Not sure if you figured this out yet, but SMTP authentication is disabled by default in Microsoft 365 now (older accounts will still have it enabled).

The easiest way to enabled it is to do this per user.

1. Log into office.com
2. Got to Microsoft365 Admin
2. Select Active users
3. Select the user to enable SMTP Authentication for
4. Select "Manage Email Apps"
5. Check the box next to "Authenticated SMTP"

for the rest the setup in Joomla Global Config is as is found in many places

From Name: Your name or website name
Reply to email: youremail
Replt to Name: Your name or website name
Mailer: SMTP
SMTP Host: smtp.office365.com
SMTP Port: 587 (25 works but 587 is preferred)
SMTP Security: STARTTLS
SMTP Authentication: Yes
SMTP username: likely your email addresss (whatever you use to log into M365)
SMTP Password: Your password at M365

I hope this helps someone

Cheers
“It is amazing how much can be accomplished if no one cares who gets the credit.”
John Wooden

User avatar
Astrophel
Joomla! Apprentice
Joomla! Apprentice
Posts: 25
Joined: Fri Dec 12, 2008 4:32 am
Location: Ottawa, ON Canada
Contact:

Re: Mail settings

Post by Astrophel » Tue Nov 29, 2022 10:12 am

Some additional research, on some accounts that does not seem to want to work even with the user having "Authenticated SMTP" enabled.

Solution: Use a connector and relay through Microsoft 365 (note that direct SMTP as suggested in some other posts works only if sending withing your organization and other Microsoft 365 users, but not outside your organization/Microsoft365).

Four Steps:
  • Enable SMTP Authentication for the organization
  • Create a connector between your organization (the website) and Microsoft 365
  • Add the website server IP to your spf record
  • Configure Joomla using MX record for Server
1. Enable SMTP for your organization
  • log into your Microsft365 Admin
  • Click Show All and go to Exchange Admin Center
  • Select Settings from the left menu
  • Select Mail Flow from the page
  • uncheck Turn off SMTP Auth protocol for your organization
Alternatively use powershell to connect to exchange using

Code: Select all

Set-TransportConfig -SmtpClientAuthenticationDisabled $false
to verify in powershell

Code: Select all

Get-TransportConfig | Format-List SmtpClientAuthenticationDisabled
2. Create a Connector between Website and Miscrosoft365
  • Stay in Exchange Admin Center
  • Click Mail Flow on the left (not the one in center of page)
  • Select Connectors
  • Select "Your Organization's email server" - "Next"
  • Name "Your Website Mailer" - whatever
  • Description "A connection between My Website and Microsft 365--or whatever... I like to be thorough :)
  • Select both Options "Turn it on" and "Retain Internal Exchange Email Header" and click "Next"
  • Use "By Verifying the IP address..... enter the IP Address of the server where your website is hosted and click the {+} button - Click Next
  • Click "Create Connector"
3. Add your ip address in spf record
  • in your hosting Control Panel edit your zone files
  • There should already be a spf record (if not go and take care of adding spf,DKIM and DMARC)
  • spf likely looks like: v=spf include:spf.protection.outlook.com -all
  • add your webserver IP Address in spf where xs are your ip address of course it will looks something like:
  • v=spf ip4:xxx.xxx.xxx.xxx include:spf.protection.outlook.com -all[
4. use your MX record for the SMTP server setting in Joomla Global Config
You should have the MX record in DNS of course already, otherwise in Microsoft Admin - Sttings - Domain - DNS records you will find them (and make sure ther are all OK while you are there, otherwise fix your DNS records on web server.
Joomla Global Config Server Tab:

From Email: [email protected]
From Name: Your Name or Site, whatever
Reply To: your email most likely
Reply to Name: your name / company name whatever
Mailer: SMTP
SMTP Host: the MX record it likely looks like yourdomain-com.mail.protection.outlook.com
SMTP Port: 25
SMTP Security: STARTTLS
SMTP Authentication: No

references:
Setting up SPF, DKIM, DMARC for Microsoft365 https://learn.microsoft.com/en-us/micro ... -worldwide

Setting up the connector (method 3): https://learn.microsoft.com/en-us/excha ... office-365

Enable/Disable SMTP AUTH in Exchange Online: https://learn.microsoft.com/en-us/excha ... submission
“It is amazing how much can be accomplished if no one cares who gets the credit.”
John Wooden

User avatar
Astrophel
Joomla! Apprentice
Joomla! Apprentice
Posts: 25
Joined: Fri Dec 12, 2008 4:32 am
Location: Ottawa, ON Canada
Contact:

Re: Mail settings

Post by Astrophel » Thu Dec 01, 2022 9:59 pm

I've done quite a bit of testing and thoought I would leave my findings so far.

TL;DR: for my setup the only method that appears to work reliably is using a connector for SMTP Relay as described above.

Some other solutions that did NOT work (using port 25,587 and tested all combinations of authentication):

1. Regular setup as per my first reply above seems to work for people in Wordpress but not Joomla, which seems counterintuitive to me also see viewtopic.php?t=985145

2. Using SMTP directly using MX record on port 25 - this will send your test email, buy will not work for emails outside of Microsoft 365. If you are sending only notification to yourself that will work OK, but if your forms send a reply to customers, you cannot use this. Unfortunately, I think many folks do this thinking stuff works.

3. Create an App password - I thought this would be the solution, but does not work for me, Authentication Continues to fail.

4. Enable Legacy SMTP on Microsoft 365 account using smtp-legacy.office365.com

Notes:
TESTING
  • All tests were performed on the same reseller cpanel account
  • All test were done on the same Microsoft365 account
  • All test were done on Joomla 4.2.5 (two different sites)
  • Do not trust the test email from Joomla to your M365 email, make sure to test an email to gmail or cpanel account as well to make sure your setup sends outside of Microsoft network.
SHORTCOMINGS:
  • You should not use this for newsletters, since this is considered a lower security method it is recommended for less than 1,000 messages a day (You should be using a bulk mailer service for such things anyway IMO)
  • Messages do not end up in your Microsoft365 mailbox since it is not sent using a user (Your forms extension should have a record id you need one, and you should send a notification to the admin/staff of the submission).
  • Messages going to your own inbox (notifications) will be subject to spam filters (setting hosting server IP in SPF record should take care of that).

I will soon do more tests to make sure gmail works and maybe from another hosting account.
“It is amazing how much can be accomplished if no one cares who gets the credit.”
John Wooden


Post Reply

Return to “Administration Joomla! 4.x”