I tested your code and work as expected! The persistent function you wrote worked fine, I just have to disable permanently defender and it worked. I didn’t change anything in it but the credentials for the email, by the way remove the file that has your email credentials from dropbox, we never know.
I compile it from kali without issues. The command used for permanently disable defender is: (You have to open a command prompt as Administrator)
REG ADD “HKLM\SOFTWARE\Policies\Microsoft\Windows Defender” /v DisableAntiSpyware /t REG_DWORD /d 1 /f
You can reboot from the windows menu, just click the windows icon in bottom left corner and select restart, then this time defender will be disabled by default.
Hope it helps!