i am trying to send emails though gmail smtp server using powershell script. but i am not able to send emails .. i am using below script-
$EmailFrom = \"btt
"The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required."
I recently ran into this issue with attempting to automate messages through my Gmail account. I do not like the option of allowing "access for less secure apps". I want forward thinking security. So I continued my search.
My solution was to enable "2-Step" verification. This provides a slightly more secure solution as it provides an alternate password for your script to access your account.
Sign in using App Passwords:
https://support.google.com/accounts/answer/185833
Stefan's link also has this solution, but it's buried in the comments and I didn't originally find it there until after I found it on my own through searching my Gmail account. That's why I am posting it here.