alekdavis/PlexBackup

Failed to send email notification (SendGrid)

Closed this issue · 4 comments

I'm trying to set up email notifications through SendGrid. I've updated my config file with the options below (relevant parts). I generated my credential file using the command in the readme. I've tested the SMTP connection outside of this script and it works as expected. However, I'm getting this error from the script.

Is there anything else I can do to help debug this error?

Failed to send email notification.
The process cannot access the file 'C:\Users\User\Desktop\20220214095622\Backup.log' because it is being used by another process.

    "SendMail": {
        "value": "Always"
    },
    "SmtpServer": {
        "value": "smtp.sendgrid.net"
    },
    "Port": {
        "value": 587
    },
    "From": {
        "value": "plex@mydomain.com"
    },
    "To": {
        "value": "myemail@gmail.com"
    },
    "NoSsl": {
        "value": null
    },
    "CredentialFile": {
        "value": "C:\\Users\\User\\Documents\\PlexBackup.ps1.xml"
    },

I am not familiar with SendGrid, so not sure how it works. The error message means that whatever process is trying to send the message cannot attach the log file because the file is still being open. I need to check to see if there is a way to close the log file sooner, but I suspect there is not. A workaround would be to set the SendLogFile property to Never (although, this should be the default, so I'm not sure why the setting doesn't get picked up). You will not get the log file as attachment, but at least, you'd get the notification.

My mistake -- I did have the SendLogFile property set to Always. I've changed this to Never and the email is now working. Turns out it wasn't related to SendGrid at all. Thanks for the help!

One quick question since it's not worth opening a new issue for... Is this the expected result of the script? (For some reason, I was expecting a single 7-zip file.)

  • YYYYMMDDHHMMSS
    • 1
      • Plex.7z
    • 2
      • Cache.7z
      • Codecs.7z
      • Media.7z
      • Metadata.7z
      • Plug-in Support.7z
      • Plug-ins.7z
    • 3
      • *.reg
    • 4
      • Plug-in Support\Data{...}
    • Backup.log
    • Version.txt

Yes, that's by design. The archived files are often huge, so splitting them into separate files helps with transfer (I hope you do not save them on the desktop, right?).

Great, thank you. I am still setting it up, but plan to save to my NAS. Thanks for your help on this.