SMTP Server with Frontend and REST API using Pode and PowerShell
This is a simple SMTP server for testing/dev purposes - built using Pode in PowerShell.
It has two servers, one for receiving email (smtp-server.ps1
) and another for a front-end/rest-api site (web-server.ps1
).
At the moment you just have to clone the repo, and it only supports Windows. Once cloned, you have two options to start running the servers:
Manually run the scripts:
Pode
, Invoke-Build
and Yarn
pode install
then pode build
smtp-server.ps1
and web-server.ps1
scripts to start the servers runningInstall the servers as Windows Services:
install.ps1
scriptPode SMTP Server
and Pode SMTP Web Server
Each server can then be accessed on the following endpoints:
localhost
, Port - 25
http://localhost:8025
(These can be configured in the repo's pode.json
file)
By default, the server is configured to automatically purge emails older than 2hrs (this can be configured in the repo's pode.json
file).
The SMTP server's website can be accessed by default on http://localhost:8025
, and allows you to see all emails being sent - including date/time, body, headers, recipients, etc.
The default endpoint for the REST API is on http://localhost:8025/api
:
Endpoint | Description | QueryString |
---|---|---|
GET /api/email/:id |
Given an EmailId, will return details about the email | none |
DELETE /api/email/:id |
Given an EmailId, will delete the email | none |
GET /api/emails |
Returns an array of paged emails | limit/page |
GET /api/emails/sender |
Returns an array of emails for an email address whom sent the email | email/limit |
GET /api/emails/recipient |
Returns an array of emails for an email address that received an email | email/limit |
Get email with ID 4:
Invoke-WebRequest 'http://localhost:8025/api/email/3' -Method Get
Delete an email with ID 4:
Invoke-WebRequest 'http://localhost:8025/api/email/3' -Method Delete
Get the first page of 10 emails, then get the 3rd page of 10 emails (emails are ordered by most recently sent):
Invoke-WebRequest 'http://localhost:8025/api/emails?limit=10&page=1' -Method Get
Invoke-WebRequest 'http://localhost:8025/api/emails?limit=10&page=3' -Method Get
Get the last 7 emails sent by an email address:
Invoke-WebRequest 'http://localhost:8025/api/emails/[email protected]&limit=7' -Method Get
Get the last 7 emails received by an email address:
Invoke-WebRequest 'http://localhost:8025/api/emails/[email protected]&limit=7' -Method Get