0
我想使用PowerShell发送电子邮件,但需要使用TLS。我可以使用Send-MailMessage cmdlet来做到这一点吗?我可以将TLS与Send-MailMessage cmdlet一起使用吗?
这是我的代码:
$file = "c:\Mail-content.txt"
if (test-path $file)
{
$from = "[email protected]"
$to = "<[email protected]>","<[email protected]>"
$pc = get-content env:computername
$subject = "Test message " + $pc
$smtpserver ="172.16.201.55"
$body = Get-Content $file | Out-String
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = { return $true }
foreach ($recipient in $to)
{
write-host "Sent to $to"
Send-MailMessage -smtpServer $smtpserver -from $from -to $recipient -subject $subject -bodyAsHtml $body -Encoding ([System.Text.Encoding]::UTF8)
}
}
else
{
write-host "Configuración"
}
非常感谢!
但它说SSL。它是否使用TLS? –
它协商任何服务器提供的,默认情况下最高的TLS 1.0或SSL 3.0 –
我明白了。那么,如果Office 365使用TLS 1.2,对吧? –