This is very 101-level basic stuff, but only after arriving at the end. Sort of like smelling something funny in the middle of the night, getting out of bed in the dark to seek out the source, and then turning on the light to realize you already stepped in it.
So, I needed to create an Orchestrator Runbook which includes an activity to send a message via Gmail SMTP/SSL. I started by adapting this example which sends SMS/MMS via Twilio (read the notes about why the author invokes a PsSession process instead of using the built-in Run PowerShell Script activity). Stripped out the Twilio stuff, the SMS/MMS/Voice message idiosyncracies (such as message limit, and also the truncate function code). It works fine. But not at first.
Running the activity and script code via the Runbook Tester, it starts off fine, and then sits for a long time. After nearly three minutes, it finally crashed with the following error…
Send-MailMessage : Unable to connect to the remote server At line:11 char:1 + Send-MailMessage -To $Recipient -From $SenderAddress -SmtpServer $GMailServer -P ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (System.Net.Mail.SmtpClient:SmtpClient) [Send-MailMessage], SmtpException + FullyQualifiedErrorId : SmtpException,Microsoft.PowerShell.Commands.SendMailMessage
After hitting my Gmail account, I see this…
And by the way, if you set up the recommended Google account “recovery” features, it will send an email to that account as well. It has a subject “Sign-in attempt prevented”.
And as before, when you change a security setting in your Google account, it sends another email to your recovery account to notify you, just in case it was someone else being malicious.
So, now the code and the Runbook activity work fine.
Just a hop, skip and a head-bump. Ouch!