Skip to content

Commit

Permalink
Allow setting a custom mail from address
Browse files Browse the repository at this point in the history
Some mail servers (e.g. Outlook.com) deny outgoing messages whose 'From'
mail address does not match the actual user account mail address.
  • Loading branch information
ComFreek committed May 15, 2018
1 parent 9a2da21 commit 10986fc
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion AU/Plugins/Mail.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
param(
$Info,
[string] $To,
[Parameter(Mandatory=$false)][string] $From,
[string] $Server,
[string] $UserName,
[string] $Password,
Expand All @@ -23,7 +24,10 @@ if (($Info.error_count.total -eq 0) -and !$SendAlways) {
$errors_word = if ($Info.error_count.total -eq 1) {'error'} else {'errors' }

# Create mail message
$from = "Update-AUPackages@{0}.{1}" -f $Env:UserName, $Env:ComputerName

if ($null -eq $From) {
$From = "Update-AUPackages@{0}.{1}" -f $Env:UserName, $Env:ComputerName
}

$msg = New-Object System.Net.Mail.MailMessage $from, $To
$msg.IsBodyHTML = $true
Expand Down

0 comments on commit 10986fc

Please sign in to comment.