I'm developing a simply monitoring too for my home and I need it to send me an email. However, no matter what I try, it is not connecting to my gmail account to send the notification - or even a simple test message. I have a script that is working for a utility I wrote for work, but that is using the corporate SMTP relay. I'm not going to mix work and personal resources.
I have spent the past 4-5 weeks digging through this and trying several other development languages. All have come up with similar problems.
I have attempted the following:
- Turned on less secure apps
- Tried a variety of ports, 25, 465, 587
- Turned on and off SSL
- Tried various forms of my username (email address)
- Turned on 2-factor authentication and created an app password for this utility
- Attempted to turn on TLS - as one error indicated I needed a starttls command.
With Powershell, I seem to get two common errors. The first one is dependent on the parameters I'm sending to the Send argument - regardless, it fails.
[Screenshot of error - ][1]
I have been on multiple forums and sites. All of the suggested code appears to be all variants of the same structure, as is the working one for my office - just using our own mail system.