-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSend-TestMail.ps1
More file actions
63 lines (53 loc) · 2.18 KB
/
Send-TestMail.ps1
File metadata and controls
63 lines (53 loc) · 2.18 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<##############################################################################
LEGAL DISCLAIMER
This Sample Code is provided for the purpose of illustration only and is not
intended to be used in a production environment. THIS SAMPLE CODE AND ANY
RELATED INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. We grant You a
nonexclusive, royalty-free right to use and modify the Sample Code and to
reproduce and distribute the object code form of the Sample Code, provided
that You agree: (i) to not use Our name, logo, or trademarks to market Your
software product in which the Sample Code is embedded; (ii) to include a valid
copyright notice on Your software product in which the Sample Code is embedded;
and (iii) to indemnify, hold harmless, and defend Us and Our suppliers from and
against any claims or lawsuits, including attorneys’ fees, that arise or result
from the use or distribution of the Sample Code.
This posting is provided "AS IS" with no warranties, and confers no rights. Use
of included script samples are subject to the terms specified
at https://www.microsoft.com/en-us/legal/copyright.
##############################################################################>
<#
.SYNOPSIS
Send e-mail
.DESCRIPTION
This is an example of how to send an e-mail.
.INPUTS
.OUTPUTS
.NOTES
Name: Send-TestMail.ps1
Authors/Contributors: Nick OConnor
DateCreated: 7/30/2021
Revisions:
#>
#Variables
#Mail Message Variables
$from = "Administrators <noreply@contoso.com>"
$bcc = "nick@contoso.com"
$to = "@"
$subject = "Test Mail Message"
$smtpServer = "smtp.contoso.com"
#Body of Mail Message
$body = {
"Classification: UNCLASSIFIED`n
Caveats: NONE`n
`n
THIS IS AN AUTOMATED MESSAGE GENERATED BY VIA SCRIPT PROCESSED BY SCHEDULEDTASK
`n
Test message sent to ensure mail relay is open to send messages
`n
Classification: UNCLASSIFIED`n
Caveats: NONE"
}
#Script
Send-MailMessage -to $to -Bcc $bcc -from $from -Subject $subject -Body $body -SmtpServer $smtpServer -ErrorAction SilentlyContinue