forked from Badgerati/Pode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmail-server.ps1
37 lines (29 loc) · 1.09 KB
/
mail-server.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
$path = Split-Path -Parent -Path (Split-Path -Parent -Path $MyInvocation.MyCommand.Path)
Import-Module "$($path)/src/Pode.psm1" -Force -ErrorAction Stop
# or just:
# Import-Module Pode
<#
Example call:
Send-MailMessage -SmtpServer localhost -To '[email protected]' -From '[email protected]' -Body 'Hello' -Subject 'Hi there' -Port 25
#>
# create a server, and start listening on port 25
Start-PodeServer -Threads 2 {
Add-PodeEndpoint -Address localhost -Protocol Smtp
# enable logging
New-PodeLoggingMethod -Terminal | Enable-PodeErrorLogging
# allow the local ip
#Add-PodeAccessRule -Access Allow -Type IP -Values 127.0.0.1
# setup an smtp handler
Add-PodeHandler -Type Smtp -Name 'Main' -ScriptBlock {
Write-Host '- - - - - - - - - - - - - - - - - -'
Write-Host $SmtpEvent.Email.From
Write-Host $SmtpEvent.Email.To
Write-Host '|'
Write-Host $SmtpEvent.Email.Body
Write-Host '|'
Write-Host $SmtpEvent.Email.Data
Write-Host '|'
$SmtpEvent.Email | Out-Default
Write-Host '- - - - - - - - - - - - - - - - - -'
}
}