locked
error in powerhell script RRS feed

  • Question

  • Here’s a full example of sending an email via Gmail’s SMTP servers. It will prompt you for a username and password thanks to (Get-Credential). The username needs to be and password needs to be , though you could always pipe in a PSCredential and get the same effect.

    ############################################################################## $From = "YourEmail@gmail.com" $To = "AnotherEmail@YourDomain.com" $Cc = "YourBoss@YourDomain.com" $Attachment = "C:\temp\Some random file.txt" $Subject = "Email Subject" $Body = "Insert body text here" $SMTPServer = "smtp.gmail.com" $SMTPPort = "587" Send-MailMessage -From $From -to $To -Cc $Cc -Subject $Subject ` -Body $Body -SmtpServer $SMTPServer -port $SMTPPort -UseSsl ` -Credential (Get-Credential) -Attachments $Attachment

    ---------------------------------------------------------------------------------

    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.7.
    0 Authentication Required. Learn more at"
    At line:16 char:1
    + $SMTPClient.Send( $emailMessage )


    nesher13

    Saturday, August 15, 2020 2:48 PM

All replies

  • you can use google translate if needed to translate your error message. All needed information provided there

    The opinion expressed by me is not an official position of Microsoft

    Friday, August 21, 2020 9:59 AM