I have to use app passwords with my scripts.

On Mon, Dec 5, 2016 at 5:29 AM Michael Leone <[email protected]> wrote:

> On Sun, Dec 4, 2016 at 9:23 PM, Michael B. Smith <[email protected]>
> wrote:
>
> I recommend you just use send-mailmessage with verbose instead of putting
> it together on your own. Probably easier and more helpful.
>
>
> I tried it that way, too. Same error.I'm trying it this way, because
> searches found blog posts that say that this is how they got it to work.
> Except it still doesn't work for me.
>
>
>
>
> I can’t speak to gApps, but Exchange requires all of EmailFrom and EmailTo
> and EmailSmtpUser to be legal Smtp users.
>
>
> No, this script used to work as shown. Then (apparently, from what I've
> read) GMail started enforcing OAuth2 authentication, and then the script
> stopped working.
>
>
>
>
>
> *From:* [email protected] [mailto:
> [email protected]] *On Behalf Of *Michael Leone
> *Sent:* Sunday, December 4, 2016 7:21 PM
> *To:* [email protected]
> *Subject:* [NTSysADM] Fwd: Can't seem to securely send to GMail
>
>
>
> So what am I doing wrong here? I want a script to send an email to my
> Gmail account (the script will run as a scheduled task). But it keeps
> failing with:
>
>
>
> Exception calling "Send" with "1" argument(s): "The SMTP server requires a
> secure connection or the client was not authenticated. The server response
> was: 5.5.1 Authentication Required. Learn more at"
>
>
>
> Even tho I am using SSl, and passing it credentials to authenticate. I
> don't really want to set my GMail account to accept less secure apps, but
> what am I doing wrong here?
>
> (I have my own Google Apps account, so I use my own domain name)
>
>
>
> $EmailFrom = "Scheduled Tasks <[email protected]>"
>
> $EmailTo = "me@my-domain"
>
> $EmailSubject = "Results of scheduled tasks"
>
> $EmailBody = "Attached is the Log"
>
>
>
> $EmailSMTPServer = "smtp.gmail.com"
>
> $EmailSMTPServerPort = "587"
>
>
>
> $EmailSMTPUser = "me@my-domain"
>
> $EmailSMTPPass = "xxxxx"
>
>
>
> $SMTPMessage = New-Object
> System.Net.Mail.MailMessage($EmailFrom,$EmailTo,$EmailSubject,$EmailBody)
>
>
>
> $SMTP = New-Object System.Net.Mail.SmtpClient($EmailSMTPServer,
> $EmailSMTPServerPort);
>
> $SMTP.EnableSSL = $true
>
> $SMTP.Credentials = New-Object
> System.Net.NetworkCredential($EmailSMTPUser, $EmailSMTPPass);
>
> $SMTP.Send($SMTPMessage);
>
>
>
> So why does it think it either doesn't have a secure connection (I am
> using EnableSsl) or not authenticating (I am passing it my Google Apps ID
> and password)?
>
>
>
> Running on Win 10, PS v5
>
>
>
> PS C:\Scripts> $psversiontable
>
>
>
> Name                           Value
>
> ----                           -----
>
> PSVersion                      5.1.14393.206
>
> PSEdition                      Desktop
>
> PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
>
> BuildVersion                   10.0.14393.206
>
> CLRVersion                     4.0.30319.42000
>
> WSManStackVersion              3.0
>
> PSRemotingProtocolVersion      2.3
>
> SerializationVersion           1.1.0.1
>
>
>
> Thanks
>
>
>
> --
-- Espi (via mobile)

Reply via email to