Magento 2 sending e-mail trough Outlook 365 Smtp

Like many others out there, we’re running our own VPS (Virtual Private Server) for our Magento 2 instance. This allows us full control over the code, security and it’s also pretty fast.

When using a VPS, you’ll need to setup e-mail yourself. You can save yourself the trouble if you have an Office 365 subscription. The only thing you have to do then is to make Magento send e-mails using the Outlook 365 Smtp server.

  • Navigate to your Magento 2 app/code directory

  • Make a directory structure like this:

 

The text in red is what’s probably different in your instance or what you’ll have to change.

  • In the folder Smtp, make a file called registration.php and insert the content from below. Make sure you change Organization_Smtp to what is appropriate for you. Don’t forget to chmod +x it :-).

  • In the folder etc, you’ll need to make two files: di.xml and module.xml

Insert the content below for di.xml and don’t forget to change Organization to what is appropriate for you.

Insert the content below for module.xml and don’t forget to change Organization to what is appropriate for you.

  • In the folder Module, you’ll need to make a file called Transport.php and insert the content below. Change Organization and username / password to what’s appropriate for you. Don’t forget to chmod +x it.

  • Now if you would order something, the confirmation e-mail will be sent trough the Outlook 365 Smtp service (if the sender is a valid Office 365 client).

Leave a Reply

Your email address will not be published. Required fields are marked *