Portable, single-binary CLI tools for testing and managing email infrastructure - both cloud (Exchange Online via Microsoft Graph) and on-premises (SMTP servers).
Repository: https://github.com/ziembor/msgraphtool
This repository contains two complementary tools for comprehensive email infrastructure testing:
- msgraphtool: Microsoft Graph API client for Exchange Online mailbox operations (send mail, calendar events, inbox management).
- smtptool: SMTP connectivity testing tool with comprehensive TLS diagnostics for on-premises Exchange servers and generic SMTP servers.
Both tools are lightweight, standalone executables requiring no additional runtimes or dependencies. Cross-platform support for Windows, Linux, and macOS with automatic CSV logging.
- Authentication: Client Secret, PFX Certificate, Windows Certificate Store (Thumbprint).
- Operations: Get Events, Send Mail, Send Invite, Get Inbox, Get Schedule, Export Inbox, Search and Export.
- Target: Exchange Online (cloud-based) mailboxes.
- Operations: Test Connect, Test STARTTLS (comprehensive TLS diagnostics), Test Auth, Send Mail.
- Diagnostics: SSL/TLS handshake analysis, certificate validation, cipher strength assessment, Exchange detection.
- Target: On-premises Exchange servers and generic SMTP servers.
- Logging: Automatic CSV logging of all operations to
%TEMP%. - Portable: Single binary, no dependencies.
- MSGRAPHTOOL_README.md: Microsoft Graph tool - Exchange Online operations
- SMTP_TOOL_README.md: SMTP tool - connectivity and email sending
- IMAPTOOL_README.md: IMAP tool - mailbox connectivity testing
- POP3TOOL_README.md: POP3 tool - message retrieval testing
- JMAPTOOL_README.md: JMAP tool - modern email protocol testing
- BUILD.md: Build instructions for all tools
- EXAMPLES.md: Microsoft Graph tool usage examples
- RELEASE.md: Release process and versioning policy
- SECURITY.md: Security policy, threat model, and best practices
- TROUBLESHOOTING.md: Common errors and solutions
# Build both tools at once
.\build-all.ps1
# Or build individually
go build -C cmd/msgraphtool -o msgraphtool.exe
go build -C cmd/smtptool -o smtptool.exeSee BUILD.md for cross-platform builds and additional options.
Microsoft Graph Tool:
# Get calendar events
.\msgraphtool.exe -tenantid "..." -clientid "..." -secret "..." -mailbox "user@example.com" -action getevents
# Send email
.\msgraphtool.exe -tenantid "..." -clientid "..." -secret "..." -mailbox "user@example.com" -action sendmailSee EXAMPLES.md for comprehensive scenarios.
SMTP Tool:
# Test SMTP connectivity
.\smtptool.exe -action testconnect -host smtp.example.com -port 25
# Test STARTTLS with comprehensive TLS diagnostics
.\smtptool.exe -action teststarttls -host smtp.example.com -port 587
# Send test email
.\smtptool.exe -action sendmail -host smtp.example.com -port 587 -username "user@example.com" -password "..." -from "sender@example.com" -to "recipient@example.com"See SMTP_TOOL_README.md for complete documentation.
When connecting to SMTP servers with encryption, there are two distinct methods:
| Method | Port | Description |
|---|---|---|
| SMTPS | 465 | Implicit TLS - encryption starts immediately upon connection |
| STARTTLS | 587 (or 25) | Explicit TLS - plain connection upgrades to TLS after STARTTLS command |
When to use SMTPS (-smtps flag):
- Port 465 connections (Gmail, many hosting providers)
- When the server expects immediate TLS handshake
- Legacy "SSL" SMTP configurations
When to use STARTTLS (-starttls flag or default):
- Port 587 connections (standard submission port)
- Port 25 connections with opportunistic encryption
- Microsoft 365 / Exchange Online
Common Provider Configurations:
| Provider | SMTPS (Port 465) | STARTTLS (Port 587) |
|---|---|---|
| Gmail | smtp.gmail.com -smtps |
smtp.gmail.com -port 587 |
| Microsoft 365 | Not supported | smtp.office365.com -port 587 |
| Yahoo | smtp.mail.yahoo.com -smtps |
smtp.mail.yahoo.com -port 587 |
# Gmail with SMTPS (implicit TLS)
smtptool -action testauth -host smtp.gmail.com -smtps -username user@gmail.com -password "app-password"
# Microsoft 365 with STARTTLS (explicit TLS)
smtptool -action testauth -host smtp.office365.com -port 587 -username user@company.com -password "password"- Microsoft Graph Tool:
MSGRAPHprefix (e.g.,MSGRAPHTENANTID,MSGRAPHSECRET) - SMTP Tool:
SMTPprefix (e.g.,SMTPHOST,SMTPPORT,SMTPUSERNAME)
- CLI flags and environment variables are trusted input from authorized users
- Not designed for untrusted web/API input or public-facing services
- Defense-in-depth measures implemented in v2.0.2+ (CRLF sanitization, v2.1.0+: password masking)
- Comprehensive security testing in v2.1.0 with 100% coverage on critical functions
- See SECURITY.md for complete threat model and deployment guidelines
Before production use:
- Review SECURITY.md for security assumptions
- Follow credential management best practices
- Restrict tool execution to authorized personnel
- Monitor CSV logs for unauthorized usage
This tool is provided as-is for testing and automation purposes.
..ooOO END OOoo..