From 9a9ad87defa307e1e7a73318c0602a6ebe6131d6 Mon Sep 17 00:00:00 2001 From: m01devsecops <166619465+m01devsecops@users.noreply.github.com> Date: Sat, 1 Jun 2024 12:03:23 +0200 Subject: [PATCH] Update Mail.ps1 Added the possibility to add a domain to the user --- src/Plugins/Mail.ps1 | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Plugins/Mail.ps1 b/src/Plugins/Mail.ps1 index ad767e9..b6d2581 100644 --- a/src/Plugins/Mail.ps1 +++ b/src/Plugins/Mail.ps1 @@ -8,6 +8,7 @@ param( [string] $Server, [string] $UserName, [string] $Password, + [string] $Domain, [int] $Port, [string[]] $Attachment, [switch] $EnableSsl, @@ -50,7 +51,13 @@ $Attachment | ForEach-Object { if ($_) { $msg.Attachments.Add($_)} } # Send mail message $smtp = new-object Net.Mail.SmtpClient($Server) -if ($UserName) { $smtp.Credentials = new-object System.Net.NetworkCredential($UserName, $Password) } +if ($UserName) { + if ($Domain) { + $smtp.Credentials = New-Object System.Net.NetworkCredential($UserName, $Password, $Domain) + } else { + $smtp.Credentials = New-Object System.Net.NetworkCredential($UserName, $Password) + } +} if ($Port) { $smtp.Port = $Port } $smtp.EnableSsl = $EnableSsl $smtp.Send($msg)