title: Can I use TLS with Send-MailMessage cmdlet?
body: <p>I am trying to send an email using PowerShell, but need to use TLS. Any way I can do that using Send-MailMessage cmdlet?</p>
  
  <p>This is my code:</p>
  
  <pre><code>$file = "c:\Mail-content.txt"
  
  if (test-path $file)
  {
  
      $from = "afgarciact@gmail.com"
      $to = "&lt;slopez@comfama.com.co&gt;","&lt;carloscu@comfama.com.co&gt;"
      $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"
  }
  </code></pre>
  
  <p>Thanks a lot! </p>