SMTP mail not sent

My client switched to Office365, so I have to set up the SMTP in MODX to make the forms work.

But mail is not sent. The form keeps spinning for a while, then reloads, then nothing (the filled in fields are still filled in). No autoResponse, no mails, no redirect page, no nothing.

This is what I have set:

  • SMTP Authentication = Yes
  • SMTP Hosts = smtp.office365.com
  • SMTP Password = your email password
  • SMTP Port = 587
  • SMTP Connection Prefix = tls
  • SMTP User = your full email address
  • Use SMTP = Yes
  • redirectTo= 253

My snippet is:
[[!FormIt?
&hooks=recaptchav2,hook.RampartFormIt,spam,email,FormItAutoResponder,redirect
&submitVar=contactForm-submit
&emailTpl=form-contact-sentEmailTpl
&emailSubject=Een bericht van [[+contact_name]]
&emailToName=Company Name
&emailTo=info@company.nl
&emailFrom=info@company.nl
]]

Strange thing is: if I set mail_smtp_auth and mail_use_smtp to ‘no’, it works fine. How is that supposed to work?

to diagnose, if sending mails works at all, you can try
Bob’s Guides | QuickEmail Snippet (bobsguides.com)

Hi handjes,

If you’re setting “mail_use_smtp” to no, it’s using the web hosts internal mail system instead, side-stepping the whole SMTP set up so all SMTP-related problems would vanish but you’re also losing the benefits of SMTP sending.

+1 to using the QuickEmail snippet. Add the ‘debug’ to that and you’ll have the best chance to discover a world of helpful information to trouble shoot the specific set up with the SMTP option.

Office / Microsoft 365, like a number of other email systems, require that you configure the SMTP relay on the servers. Without this, the SMTP relay is rejected and you cannot send your email from your application.

In Office 365 (which uses a Microsoft Exchange server), this is setup is called “connectors”. To configure this, go to the Office 365 Admin center, then select the Microsoft Exchange admin center and select the “Mail Flow” => “Connectors” option. On this page, there is a link to some help documents from Microsoft regarding the setup of an appropriate connector.

Here is a link to the general help document from Microsoft: Do I need to create a connector in Exchange Online? | Microsoft Docs

in your case, I suggest you follow the procedure under the third point “All of your mailboxes are in Exchange Online, but you need to send email from sources in your on-premises organization” => How to set up a multifunction device or application to send email using Microsoft 365 or Office 365 | Microsoft Docs

Hope this helps