Skip to content

ziembor/gomailtesttool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

172 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Microsoft Graph & SMTP Testing Tools

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

Purpose

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.

Key Features

Microsoft Graph Tool (msgraphtool)

  • 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.

SMTP Tool (smtptool)

  • 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.

Both Tools

  • Logging: Automatic CSV logging of all operations to %TEMP%.
  • Portable: Single binary, no dependencies.

Documentation

Tool-Specific READMEs

General Documentation

Quick Start

Build Both Tools

# 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.exe

See BUILD.md for cross-platform builds and additional options.

Usage Examples

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 sendmail

See 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.

SMTPS vs STARTTLS

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"

Environment Variables

  • Microsoft Graph Tool: MSGRAPH prefix (e.g., MSGRAPHTENANTID, MSGRAPHSECRET)
  • SMTP Tool: SMTP prefix (e.g., SMTPHOST, SMTPPORT, SMTPUSERNAME)

Security Considerations

⚠️ Important: These are diagnostic CLI tools designed for authorized personnel (system administrators, IT staff).

  • 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:

  1. Review SECURITY.md for security assumptions
  2. Follow credential management best practices
  3. Restrict tool execution to authorized personnel
  4. Monitor CSV logs for unauthorized usage

License

This tool is provided as-is for testing and automation purposes.

                      ..ooOO END OOoo..

About

simple codevibed tool for test MSGraph in EXO RBAC for application scope.

Resources

License

Security policy

Stars

Watchers

Forks

Contributors