Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 29918

Send-MailMessage on PowerShell does not work

$
0
0

I have a big problem. For a school club I have to write a script which sends emails automatically. I decided to use PowerShell for that.

My Code:

Send-MailMessage –To "email@outlook.com"–Subject "Test E-Mail"–Body "FIRST EMAIL WITH POWERSHELL"–SmtpServer "smtp.gmail.com"–From "email@gmail.com"

My error code:

Send-MailMessage: The SMTP server requires a secure connection or the client has not been authenticated. The server response was: 5.7.0 Must issue a STARTTLS command first. o3sm51888528wrs.30 - gsmtp In line: 1 character: 1 + Send-MailMessage -To "email@outlook.com" Subject "Test E-Mail" -Bod ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~ + CategoryInfo: InvalidOperation: (System.Net.Mail.SmtpClient: SmtpClient) [Send-MailMessage], SmtpException + FullyQualifiedErrorId: SmtpException, Microsoft.PowerShell.Commands.SendMailMessage

And if I write

–SmtpServer "gsmtp.gmail.com"

the error code is:

Send-MailMessage : The connection to the remote server cannot be established. In line:1 character:1 + Send-MailMessage -To "email@outlook.com"; -Subject "Test E-Mail"; -Bod . . . + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (System. Net. Mail. SmtpClient:SmtpClient) [Send-MailMessage], SmtpException + FullyQualifiedErrorId : SmtpException,Microsoft. PowerShell. Commands. SendMailMessage

Do you know what´s the problem?


Viewing all articles
Browse latest Browse all 29918

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>