-
-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #986 from Badgerati/develop
v2.7.0
- Loading branch information
Showing
97 changed files
with
34,404 additions
and
937 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# These are supported funding model platforms | ||
|
||
github: [Badgerati] | ||
ko_fi: badgerati | ||
custom: ["https://www.paypal.me/badgerati"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM mcr.microsoft.com/powershell:7.2.1-ubuntu-20.04 | ||
FROM mcr.microsoft.com/powershell:7.2-ubuntu-20.04 | ||
LABEL maintainer="Matthew Kelly (Badgerati)" | ||
RUN mkdir -p /usr/local/share/powershell/Modules/Pode | ||
COPY ./pkg/ /usr/local/share/powershell/Modules/Pode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM mcr.microsoft.com/powershell:7.2.1-alpine-3.14-20211209 | ||
FROM mcr.microsoft.com/powershell:7.2-alpine-3.14 | ||
LABEL maintainer="Matthew Kelly (Badgerati)" | ||
RUN mkdir -p /usr/local/share/powershell/Modules/Pode | ||
COPY ./pkg/ /usr/local/share/powershell/Modules/Pode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM mcr.microsoft.com/powershell:7.2.1-arm32v7-ubuntu-18.04-20211209 | ||
FROM mcr.microsoft.com/powershell:7.2-arm32v7-ubuntu-18.04 | ||
LABEL maintainer="Matthew Kelly (Badgerati)" | ||
RUN mkdir -p /usr/local/share/powershell/Modules/Pode | ||
COPY ./pkg/ /usr/local/share/powershell/Modules/Pode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,13 @@ | ||
# SMTP Server | ||
# SMTP | ||
|
||
Pode has an inbuilt SMTP server for receiving Email which automatically creates a TCP listener on port 25 - unless you specify a different port via the [`Add-PodeEndpoint`](../../Functions/Core/Add-PodeEndpoint) function. | ||
|
||
Unlike with web servers that use the Route functions, SMTP servers use the Handler functions, which let you specify logic for handling responses from TCP streams. | ||
Pode has an inbuilt SMTP server for receiving emails, with support for non-TLS as well as implicit and explicit TLS. Unlike with web servers that use the Route functions, an SMTP server use the Handler functions, which let you specify logic for handling responses from TCP streams. | ||
|
||
!!! tip | ||
You can setup multiple different Handlers to run different logic for one Email. | ||
You can setup multiple different Handlers to run different logic for one email. | ||
|
||
## Usage | ||
|
||
To create a Handler for the inbuilt SMTP server you can use the following example: | ||
To create a Handler for the SMTP server you can use the following example: | ||
|
||
```powershell | ||
Start-PodeServer { | ||
|
@@ -23,14 +21,43 @@ Start-PodeServer { | |
} | ||
``` | ||
|
||
Starting this server will listen for incoming email on `localhost:25`. The Handler will have access to the `$SmtpEvent` object (see below), which contains information about the Email. | ||
Starting this server will listen for incoming email on `localhost:25`. The Handler will have access to an `$SmtpEvent` object (see below), which contains information about the received email. | ||
|
||
An example of sending Email to the above server via `Send-MailMessage`: | ||
An example of sending an email to the above server via `Send-MailMessage`: | ||
|
||
```powershell | ||
Send-MailMessage -SmtpServer localhost -To '[email protected]' -From '[email protected]' -Body 'Hello' -Subject 'Hi there' -Port 25 | ||
``` | ||
|
||
## TLS | ||
|
||
You can enable TLS for your endpoints by supplying the normal relevant certificates parameters on [`Add-PodeEndpoint`](../../Functions/Core/Add-PodeEndpoint), and setting the `-Protocol` to `Smtps`. You can also toggle between implicit and explicit TLS by using the `-TlsMode` parameter. | ||
|
||
By default the TLS mode is implicit, and the default port for implicit TLS is 465; for explicit TLS it's 587. These can of course be customised using `-Port`. | ||
|
||
```powershell | ||
Start-PodeServer { | ||
Add-PodeEndpoint -Address * -Protocol Smtps -SelfSigned -TlsMode Explicit | ||
Add-PodeEndpoint -Address * -Protocol Smtps -SelfSigned -TlsMode Implicit | ||
Add-PodeHandler -Type Smtp -Name 'Main' -ScriptBlock { | ||
Write-Host $SmtpEvent.Email.From | ||
Write-Host $SmtpEvent.Email.To | ||
Write-Host $SmtpEvent.Email.Body | ||
} | ||
} | ||
``` | ||
|
||
.NET only supports explicit TLS, so an example of sending an email to the explicit TLS endpoint, on port 587, is as follows: | ||
|
||
```powershell | ||
# if using a self signed cert, make sure to run the below | ||
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = { return $true } | ||
# send the email | ||
Send-MailMessage -SmtpServer localhost -To '[email protected]' -From '[email protected]' -Body 'Hello' -Subject 'Hi there' -Port 587 -UseSSL | ||
``` | ||
|
||
## Attachments | ||
|
||
The SMTP server also accepts attachments, which are available in a Handler via `$SmtpEvent.Email.Attachments`. This property contains a list of available attachments on the Email, each attachment has a `Name` and `Bytes` properties - the latter being the raw byte content of the attachment. | ||
|
@@ -55,6 +82,8 @@ The SMTP Handler will be passed the `$SmtpEvent` object, that contains the Reque | |
| Response | object | The raw Response object | | ||
| Lockable | hashtable | A synchronized hashtable that can be used with `Lock-PodeObject` | | ||
| Email | hashtable | An object containing data from the email, as seen below | | ||
| Endpoint | hashtable | Contains the Address and Protocol of the endpoint being hit - such as "pode.example.com" or "127.0.0.2", or HTTP or HTTPS for the Protocol | | ||
| Timestamp | datetime | The current date and time of the Request | | ||
|
||
|
||
|
Oops, something went wrong.