<# Simple script to send a log file after btrfs backup #> $EmailAttachments = "/attachment/btrfs_log.log" # Email Setup $SMTPServer = "mx.digimapas.cl" $SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 587) $SMTPClient.EnableSsl = $true $user = "no_reply_it@digimapas.cl" $pw = ConvertTo-SecureString "PASSWORD" -AsPlainText -Force $SMTPClient.Credentials = New-Object System.Management.Automation.PSCredential($user, $pw) $emailMessage = New-Object System.Net.Mail.MailMessage $emailMessage.From = new-object System.Net.Mail.MailAddress($user, "Backup ...") $emailMessage.to.Add("RECEIVER@digimapas.cl") $emailMessage.From = $user $emailMessage.IsBodyHTML = $false <# to create readablity the email is formatted as html table #> $htmlEmailBody = ("Backup ...`n") foreach($line in Get-Content $EmailAttachments) { $htmlEmailBody += @($line) $htmlEmailBody += @("`n") } if($EmailAttachments.length -gt 0){ foreach($EmailAttachment in $EmailAttachments){ Write-Host $EmailAttachment $emailMessage.Attachments.Add($EmailAttachment) } } $emailMessage.Subject = "Backup Webservices DMCL" $emailMessage.Body = "$htmlEmailBody" $SMTPClient.Send($emailMessage)