I'm trying to figure out how to use PowerShell V2's Send-MailMessage with gmail.
Here's what I have so far.
$ss = new-object Security.SecureString
foreach ($ch in "password".ToCharArray())
{
$ss.AppendChar($ch)
}
$cred = new-object Management.Automation.PSCredential "
[email protected]", $ss
Send-MailMessage -SmtpServer smtp.gmail.com -UseSsl -Credential $cred -Body...
I get the following error
Send-MailMessage : 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
At foo.ps1:18 char:21
+ Send-MailMessage <<<< `
+ CategoryInfo : InvalidOperation: (System.Net.Mail.SmtpClient:SmtpClient) [Send-MailMessage], SmtpException
+ FullyQualifiedErrorId : SmtpException,Microsoft.PowerShell.Commands.SendMailMessage
Am I doing something wrong, or is Send-MailMessage not fully baked yet (I'm on CTP 3)?
Edit - two additional restrictions
I want this to be non-interactive, so get-credential won't work
The user account isn't on the gmail domain, but an google apps registered domain