Send e-mail with powershell

 Create a file with ps1 extension, like send_mail.ps1, with this content:


# Make Windows negotiate higher TLS version:
[System.Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

Send-MailMessage -From from@example.com -To to@example.com -Credential (Get-Credential) -Subject "Hello World" -Body "Your text here" -SmtpServer "smtp.office365.com" -Port 587 -UseSsl 

 

 With cred:

# Make Windows negotiate higher TLS version:
[System.Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

$secpasswd = ConvertTo-SecureString "PlainTextPassword" -AsPlainText -Force
$Cred = New-Object System.Management.Automation.PSCredential ("username", $secpasswd)
$EmailTo = "myself@gmail.com"
$EmailFrom = "me@mydomain.com"
$Subject = "Test"
$Body = "Test Body"
$SMTPServer = "smtp.gmail.com"

Send-MailMessage -From $EmailFrom -To $EmailTo -Credential $Cred -Subject $Subject -Body $Body -SmtpServer $SMTPServer -Port 587 -UseSsl

Mobile Access SSL Network Extender (SNX) remote users with Windows 11 24H2 fail to connect

  Cause The conflict resolution mechanism in Windows 11 24H2 is different than in earlier versions of Windows. Solution On the Windows endpo...

Mais vistos