Send mail via Gmail with PowerShell V2's Send-MailMessage

前端 未结 13 2063
一生所求
一生所求 2020-11-30 21:07

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         


        
13条回答
  •  孤独总比滥情好
    2020-11-30 21:24

    This should fix your problem:

    $credentials = New-Object Management.Automation.PSCredential “mailserver@yourcompany.com”, (“password” | ConvertTo-SecureString -AsPlainText -Force)
    

    Then use the credential in your call to Send-MailMessage -From $From -To $To -Body $Body $Body -SmtpServer {$smtpServer URI} -Credential $credentials -Verbose -UseSsl

提交回复
热议问题