Guide
Send Email from PowerShell
PowerShell deprecated Send-MailMessage in version 7.0, and configuring raw SMTP from scripts means hardcoding credentials. Nylas CLI is a single Go binary that handles OAuth2, provider abstraction, and connection management. Install it, authenticate once, and send email from PowerShell with one command.
Why not raw SMTP from PowerShell?
PowerShell's Send-MailMessage was deprecated in PowerShell 7.0 because it cannot negotiate TLS securely. The alternatives -- System.Net.Mail.SmtpClient and direct socket connections -- require you to hardcode SMTP credentials, manage app passwords, and handle provider-specific quirks. Gmail requires OAuth2 or app passwords with 2FA. Outlook requires an app registration in Azure AD. Every provider is different.
Nylas CLI abstracts all of this. One binary, one authentication flow, every provider.
1. Install Nylas CLI on Windows
Nylas CLI is a single Go binary. Install it with one command:
# One-liner install for PowerShell
irm https://cli.nylas.com/install.ps1 | iex
# Or install with Go (requires Go 1.23+)
# go install github.com/nylas/cli/cmd/nylas@latestVerify the installation:
nylas --version2. Authenticate your mailbox
Head to dashboard-v3.nylas.com, create an application, and connect your mailbox. Then configure the CLI:
# Configure your API key
nylas auth config
# Paste your API key when prompted
# Verify it works
nylas auth whoami
# => Authenticated as you@company.com (Google Workspace)3. Send a basic email
nylas email send `
--to "colleague@company.com" `
--subject "Quarterly report" `
--body "Hi -- please review the Q4 numbers before Friday."
# Skip the confirmation prompt
nylas email send `
--to "user@example.com" `
--subject "Quick note" `
--body "This is a quick note." `
--yes4. Send to multiple recipients
# To, CC, and BCC
nylas email send `
--to "alice@team.com" `
--cc "bob@team.com" `
--bcc "manager@team.com" `
--subject "Sprint update" `
--body "All tasks on track for this sprint."
# Multiple --to recipients
nylas email send `
--to "alice@team.com" `
--to "bob@team.com" `
--to "carol@team.com" `
--subject "Team sync" `
--body "Meeting moved to 3pm." `
--yes5. Send with attachments
# Single attachment
nylas email send `
--to "client@example.com" `
--subject "Invoice attached" `
--body "Please find the invoice for March." `
--attach "C:UsersyouDocumentsinvoice-march.pdf"
# Multiple attachments
nylas email send `
--to "client@example.com" `
--subject "Project deliverables" `
--body "Attached are the final designs and spec." `
--attach "C:UsersyouDocumentsdesign.png" `
--attach "C:UsersyouDocumentsspec.docx" `
--yes6. Send HTML email
Pass HTML directly in the --body flag, or pipe it from a file:
# Inline HTML body
nylas email send `
--to "team@company.com" `
--subject "Weekly digest" `
--body "<h1>Weekly Digest</h1><p>Here are this week's highlights:</p><ul><li>Feature A shipped</li><li>Bug B fixed</li></ul>" `
--yes
# HTML body from a file
$htmlBody = Get-Content -Path ".email-template.html" -Raw
nylas email send `
--to "team@company.com" `
--subject "Newsletter" `
--body $htmlBody `
--yes7. Pipe body from a file
For long plain-text bodies, read the content into a variable and pass it to --body:
# Read body from a text file
$body = Get-Content -Path ".message.txt" -Raw
nylas email send `
--to "recipient@example.com" `
--subject "Status update" `
--body $body `
--yes
# Read body from file
$body = Get-Content ".\message.txt" -Raw
nylas email send `
--to "recipient@example.com" `
--subject "Status update" `
--body $body `
--yes8. Schedule emails for later
# Send in 2 hours
nylas email send `
--to "team@company.com" `
--subject "Reminder" `
--body "Don't forget the standup." `
--schedule "2h"
# Send tomorrow morning
nylas email send `
--to "team@company.com" `
--subject "Standup agenda" `
--body "Please add your items." `
--schedule "tomorrow 9am"
# Send on a specific date
nylas email send `
--to "client@example.com" `
--subject "Follow-up" `
--body "Checking in on the proposal." `
--schedule "2026-03-20 14:30"9. JSON output and PowerShell scripting
Every Nylas CLI command supports --json output. Use PowerShell's ConvertFrom-Json to parse it:
# Count unread emails
$unread = nylas email list --unread --json | ConvertFrom-Json
Write-Host "Unread emails: $($unread.Count)"
# Get subjects of unread emails
$unread | ForEach-Object { Write-Host $_.subject }
# Find urgent emails
$urgent = nylas email list --unread --json |
ConvertFrom-Json |
Where-Object { $_.subject -match "urgent|asap" }
Write-Host "Urgent emails: $($urgent.Count)"
# Send results to a file
nylas email list --limit 50 --json |
ConvertFrom-Json |
Select-Object subject, from, date |
Export-Csv -Path ".inbox-report.csv" -NoTypeInformation10. Bulk send from a CSV
# contacts.csv: Email,Name
# alice@team.com,Alice
# bob@team.com,Bob
Import-Csv -Path ".contacts.csv" | ForEach-Object {
nylas email send `
--to $_.Email `
--subject "Hello $($_.Name)" `
--body "Your account is ready." `
--yes
Start-Sleep -Seconds 2
}Frequently asked questions
Can I send email from PowerShell without Send-MailMessage?
Yes. Install Nylas CLI, authenticate once, and use nylas email send. It handles OAuth2 and TLS negotiation automatically -- no SMTP credentials, no deprecated cmdlets.
Does Nylas CLI work in PowerShell on Windows?
Yes. Nylas CLI is a Go binary that runs natively on Windows. It works in PowerShell 5.1, PowerShell 7+, Command Prompt, and Windows Terminal. All commands and flags are identical across shells.
How do I send HTML email from PowerShell?
Pass HTML in the --body flag or read it from a file with Get-Content -Raw. The CLI detects HTML content automatically and sets the correct MIME type.
Can I schedule emails from PowerShell?
Yes. Add --schedule "2h" or --schedule "tomorrow 9am" to any send command. Supports relative times and absolute dates.
Next steps
- Replace Send-MailMessage with Nylas CLI -- side-by-side migration from the deprecated cmdlet
- Send email from the terminal -- the full guide covering bash, zsh, and more
- Full command reference -- every flag and subcommand documented
- Give AI agents email access via MCP -- set up Claude, Cursor, or any MCP client