kmwoley / restic-windows-backup

Powershell scripts to run Restic backups on Windows
MIT License
322 stars 67 forks source link

Email sent from backup task fails on Windows 11 #100

Open ckewinjones opened 3 weeks ago

ckewinjones commented 3 weeks ago

The email functionality of backup.ps1 fails on my Windows 11 install of restic-windows-backup. The error log shows the following:

Send-MailMessage : Unable to read data from the transport connection: net_io_connectionclosed.
At C:\restic\backup.ps1:337 char:9
+         Send-MailMessage @ResticEmailConfig -From $ResticEmailFrom -T ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.Mail.SmtpClient:SmtpClient) [Send-MailMessage], SmtpExcept 
   ion
    + FullyQualifiedErrorId : SmtpException,Microsoft.PowerShell.Commands.SendMailMessage

[[Email]] Sending email completed with errors

Per the documentation of the Send-MailMessage cmdlet, Send-MailMessage is obsolete and has been deprecated in favor of the Send-MailKitMessage cmdlet available in PSGallery. I have fixed this in my own installation of restic-windows-backup by

I will make my changes available in a pull request so that this change can be part of the next release of restic-windows-backup if that is wanted.

The failure occurs on my system running Windows 11 Pro 23H2. I don't know if it occurs on any earlier versions of Windows 11 or Windows 10. By the same token I don't know if my fix works on any other Windows version either. I would be willing to test other platforms (by spinning up VMs for each platform that needs testing) if that would be helpful.

ckewinjones commented 3 weeks ago

See PR 101