---
title: "Send Email with Office 365 Direct Send and PowerShell"
description: "Send emails using Office 365 Direct Send and SMTP Authenticated Submission with PowerShell."
canonical: "https://adamtheautomator.com/office-365-direct-send/"
---

# Send Email with Office 365 Direct Send and PowerShell

> Send emails using Office 365 Direct Send and SMTP Authenticated Submission with PowerShell.

Source: https://adamtheautomator.com/office-365-direct-send/

---

ATA Learning

Tap to hide

[

ATA Learning

](/)

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Search for:  

*   [](https://twitter.com/adbertram)
*   [](https://github.com/Adam-the-Automator)
*   [](https://www.linkedin.com/company/adam-the-automator-llc)
*   [](/feed/)

![Send Email with Office 365 Direct Send and PowerShell](https://adamtheautomator.com/wp-content/uploads/2019/09/email-office-365.png)

# Send Email with Office 365 Direct Send and PowerShell

[![](https://secure.gravatar.com/avatar/9a14f10ff1b1ec7d790d34f5b559e4d3de2d31b172e6ef266dfd8b479174d97b?s=192&d=mm&r=g)June Castillote](https://adamtheautomator.com/author/june/)6 September 20193 min. read

Categories: [Cloud](/category/cloud/)

Tags:[Office 365](/tag/office-365/)[PowerShell](/tag/powershell/)

Table of Contents

*   [Office 365 Direct Send vs. SMTP Client Submission](#direct-send-vs-smtp-client-submission)
*   [SMTP Authenticated Submission](#smtp-authenticated-submission)
*   [Direct Send](#direct-send)
*   [SMTP Authenticated Submission](#smtp-authenticated-submission-1)
*   [Direct Send (TLS Required)](#direct-send-tls-required-)
*   [Summary](#summary)
*   [Further Reading](#further-reading)

Did you know you can use Office 365 to send email with PowerShell? In this article, you’re going to learn how to send Email with Office 365 Direct Send and PowerShell’s `Send-MailMessage` cmdlet.

> _If you’d like an in depth look at sending email with PowerShell, check out this [in-depth tutorial on Send-MailMessage](https://adamtheautomator.com/send-mailmessage/)._

## Office 365 Direct Send vs. SMTP Client Submission

Before we get too far into the PowerShell, know that there’s not just one way to send email through Office 365 using PowerShell. Office 365 has two supported ways to send email. Those options are _Direct Send_ and _SMTP Client Submission_ or _SMTP Authenticated Submission_.

### SMTP Authenticated Submission

SMTP Authenticated Submission is the easiest to set up. You would choose this option if you plan to send emails from a device or application to recipients inside and outside your organization. There is no extra action to do in Office 365 to allow this.

This option allows you to use any sender address. But the address must be from one of your verified accepted domains.

To use _SMTP Authenticated Submission_, you must:

*   Have an Office 365 user mailbox (licensed). This email address will appear as the sender of the message.
*   PowerShell (or another client) must be able to resolve and reach _smtp.office365.com_.
*   TCP Port 587 or 25 must be open to Office 365 from the client.

### Direct Send

Ramping up the complexity a bit is the _Direct Send_ option. Like _SMTP Authenticated Submission_, _Direct Send_ allows you to use any sender address. Also, the _from_ address must be from one of your verified accepted domains.

The big difference between _Direct Send_ and _SMTP Authenticated Submission_ is no external recipients are allowed. _If you need to send to email recipients outside of your organization, Direct Send will not work for you_.

_Direct Send_ has a few of its own requirements/recommendations:

*   This sender address does not have to be a valid mailbox. But it is needed if you plan to receive NDRs or replies using this address.
*   TCP Port 25 is open from your client to Office 365.
*   The device must be able to resolve and reach your MX endpoint URL (eg. _yourdomain-com.mail.protection.outlook.com_)
*   A static public IP address_._ This is to update your SPF record and avoid your messages getting flagged as spam (optional but recommended)

If you don’t know how to find your MX endpoint URL, here’s a quick tutorial:

1.  Log into the [Office 365 Admin Portal](https://portal.office.com/adminportal).
2.  Click on _Setup **(1)**_, select _Domains **(2)**_, click the _Domain name **(3)**_, copy the MX _Points to address or value **(4).**_

![Finding Office 365 MX Endpoint URL](https://adamtheautomator.com/wp-content/uploads/2020/06/the-MX-Points-to-address-or-value-4.-1024x488.png)

Finding Office 365 MX Endpoint URL

## SMTP Authenticated Submission

The first method to send email is via SMTP Client Submission or SMTP Authenticated Submission. Using PowerShell’s `Send-MailMessage` cmdlet, we can provide all of the parameters we need to send email through Office 365.

Below is a snippet you can use to send email via this method.

You’ll first need to define a [PowerShell PScredential object](https://adamtheautomator.com/powershell-get-credential/) then provide all of the parameters that `Send-MailMessage` needs.

```powershell
# Get the credential
$credential = Get-Credential

## Define the Send-MailMessage parameters
$mailParams = @{
    SmtpServer                 = 'smtp.office365.com'
    Port                       = '587' # or '25' if not using TLS
    UseSSL                     = $true ## or not if using non-TLS
    Credential                 = $credential
    From                       = 'sender@yourdomain.com'
    To                         = 'recipient@yourdomain.com', 'recipient@NotYourDomain.com'
    Subject                    = "SMTP Client Submission - $(Get-Date -Format g)"
    Body                       = 'This is a test email using SMTP Client Submission'
    DeliveryNotificationOption = 'OnFailure', 'OnSuccess'
}

## Send the message
Send-MailMessage @mailParams
```

When you run the code above, you should receive an email received by the internal recipient (_yourdomain.com_) and the external domain (_notyourdomain.com_).

![Message received by the internal recipient](https://adamtheautomator.com/wp-content/uploads/2020/06/and-the-external-domain-notyourdomain.com_..png "image_tooltip")

Internal Email

![Message received by the external recipient](https://adamtheautomator.com/wp-content/uploads/2020/06/and-the-external-domain-notyourdomain.com_.2.png "image_tooltip")

External email

## Direct Send (TLS Required)

Similar to _SMTP Authenticated Submission_, you can use nearly the same parameters for `Send-MailMessage`. However this time, the `To` recipients will only be internal.

Also notice that a PSCredential was not needed.

```powershell
## Build parameters
$mailParams = @{
    SmtpServer                 = '<tenant>.mail.protection.outlook.com'
    Port                       = '25'
    UseSSL                     = $true   
    From                       = 'sender@yourdomain.com'
    To                         = 'recipient@yourdomain.com'
    Subject                    = "Direct Send $(Get-Date -Format g)"
    Body                       = 'This is a test email using Direct Send'
    DeliveryNotificationOption = 'OnFailure', 'OnSuccess'
}

## Send the email
Send-MailMessage @mailParams
```

![Message received by the internal recipient using Direct Send](https://adamtheautomator.com/wp-content/uploads/2020/06/and-the-external-domain-notyourdomain.com_.3.png "image_tooltip")

Direct Send email

## Summary

You can see that Office 365 provides two different options for sending email. In this article, we used PowerShell as an example to demonstrate both. But you don’t have to use PowerShell. As long as your application or programming language supports TLS authentication, you can use any method you’d like.

## Further Reading

*   **_[The Underused Power of the Microsoft Graph API with PowerShell](https://adamtheautomator.com/powershell-graph-api/)_**
*   **_[How to set up a multifunction device or application to send email using Office 365](https://docs.microsoft.com/en-us/Exchange/mail-flow-best-practices/how-to-set-up-a-multifunction-device-or-application-to-send-email-using-microsoft-365-or-office-365)_**

Share this article

[Share on X](https://twitter.com/intent/tweet?url=https%3A%2F%2Fadamtheautomator.com%2Foffice-365-direct-send%2F&text=Send%20Email%20with%20Office%20365%20Direct%20Send%20and%20PowerShell)[Share on Facebook](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fadamtheautomator.com%2Foffice-365-direct-send%2F)[Share on LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fadamtheautomator.com%2Foffice-365-direct-send%2F)

## Related Posts

![](https://adamtheautomator.com/wp-content/uploads/2020/01/problem-67054_1920.jpg)

### [Export Office 365 Audit Logs with PowerShell](/export-audit-log-office-365/)

Master the art of exporting Office 365 audit logs and parsing administrator logs using PowerShell. Improve your IT security and reporting skills.

![](https://adamtheautomator.com/wp-content/uploads/2026/08/featured_image-3.webp)

### [Build an Azure Home Lab for Certs Without Overspending](/azure-home-lab-certification-practice/)

Build a nested Azure Hyper-V home lab with budget alerts, a domain controller, and Azure Arc mapped to AZ-900, AZ-104, and AZ-305 exams.

![](https://adamtheautomator.com/wp-content/uploads/2026/04/featured_image-16.webp)

### [Microsoft 365 E7: Is the $99/User Price Tag Worth It?](/microsoft-365-e7-99user-price-tag-worth-it/)

Evaluate whether Microsoft 365 E7’s $99 price justifies Agent 365 governance using PowerShell scripts to assess Copilot usage and automation risk exposure.

## Categories

*   [IT Ops](/category/it-ops/)
*   [Cloud](/category/cloud/)
*   [DevOps](/category/devops/)
*   [Home Ops](/category/home-ops/)
*   [Information Security](/category/infosec/)
*   [Software Development](/category/software-development/)

## Site

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Copyright 2026© ATA Learning | [Privacy Policy](/privacy/)
