Skip to content
Advertisement

Setting up PHPMailer with Office365 SMTP

I am attempting to set up PHPMailer so that one of our clients is able to have the automatically generated emails come from their own account. I have logged into their Office 365 account, and found that the required settings for PHPMailer are:

JavaScript

I have applied these settings to PHPMailer, however no email gets sent (The function I call works fine for our own mail, which is sent from an external server (Not the server serving the web pages)).

JavaScript

Does anyone know what settings are required to get PHPMailer to send via smtp.office365.com?

Advertisement

Answer

@nitin’s code was not working for me, as it was missing ‘tls’ in the SMTPSecure param.

Here is a working version. I’ve also added two commented out lines, which you can use in case something is not working.

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement