Отправка почты через gmail с помощью PowerShell V2 Send-MailMessage
Я пытаюсь понять, как использовать PowerShell V2.Send-MailMessage
с Gmail.
Вот что я имею до сих пор.
$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...
Я получаю следующую ошибку
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
Я делаю что-то не так илиSend-MailMessage
еще не испечен полностью (я на CTP 3)?
Некоторые дополнительные ограничения
I want this to be non-interactive, soget-credential
won't work
The user account isn't on the gmail domain, but an google apps registered domain
For this question, I'm only interested in the Send-MailMessage
cmdlet, sending mail via the normal .Net API is well understood.