SMTP – How WebApp Can Send Emails via Outlook.com Mail Account

email-serversmtp

I have a web app running on a shared server account for the domain example.com.
The web app needs to send the occasional email to the app adminstrator.

The domain example.com is using Outlook.com as the email server.

How can I either:

a) Configure the web app to send emails via an Outlook.com mail account (can you point me to the instructions/settings to configure this?), or

b) Configure the included mail server for the domain to send emails even though the domain is configured to use Outlook.com? (I do not think this option is possible), or

c) Purchase an additional domain, add it to the same "account", and access it from the web app running on example.com?

Has anyone done this, and can you point me in the right direction re configuration recipe?

Best Answer

One of the reasons its difficult to find information about this is because Microsoft keeps changing its API. For example, these two links show an API in change, that works now but will be obsolete in a few months.

this one

and this one

If you can't get this working, here's another idea:

Register another domain (e.g. examplebot.com) and add it to your hosting account as an add-on domain. Because it's part of the same hosting account, the primary domain can send email through it bypassing the Outlook.com servers entirely.

Here's what the config would look like under NodeJS:

First, you would need to install the nodemailer package.

Then, in your App.js (or whatever you called your backend file):

const nodemailer = require('nodemailer');

const transporter = nodemailer.createTransport({
    host: 'mail.examplebot.com',
    port: 465,
    secure: true,
    auth: {
       user: '[email protected]',
       pass: 's3cr3tPassword',
    },
    tls: {
       rejectUnauthorized: false,
    },
});

Of course, you would need to create a mailbox for the user specified in your code ([email protected] / s3cr3tPassword).

I've done this before, specifically to get around the need to send emails through the Microsoft Office365 environment, and it worked for me.

Related Topic