mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-08-09 21:07:40 +02:00
Added send-email.ps1
This commit is contained in:
20
Scripts/send-email.ps1
Executable file
20
Scripts/send-email.ps1
Executable file
@ -0,0 +1,20 @@
|
||||
#!/snap/bin/powershell
|
||||
|
||||
# Syntax: ./email.ps1
|
||||
# Description: sends an email
|
||||
# Author: Markus Fleschutz
|
||||
# Source: github.com/fleschutz/PowerShell
|
||||
# License: CC0
|
||||
|
||||
try {
|
||||
$smtpServer = "smtp.example.com"
|
||||
$msg = new-object Net.Mail.MailMessage
|
||||
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
|
||||
$msg.From = "me@example.com"
|
||||
$msg.ReplyTo = "me@example.com"
|
||||
$msg.To.Add("you@example.com")
|
||||
$msg.subject = "Test Mail"
|
||||
$msg.body = "This is a test mail."
|
||||
$smtp.Send($msg)
|
||||
} catch { Write-Error $Error[0] }
|
||||
exit 1
|
Reference in New Issue
Block a user