2

According to the cmdlet help file, Send-MailMessage is no longer recommended for sending email, especially to SMTP servers.

The .NET Platform Compatibility Note, which the documentation leads to, says to use the MailKit .NET library. Upon examining that library's documentation, it found that it's primarily for use with C#. However I want to send email directly from PowerShell.

Are there other options for carrying out this task?

Steven
  • 6,817
  • 1
  • 14
  • 14
BroVic
  • 979
  • 9
  • 26
  • 3
    Nothing prevents you from loading MailKit into PowerShell and calling its methods, e.g. https://www.leeholmes.com/blog/2006/10/27/load-a-custom-dll-from-powershell/ – Ian Kemp Oct 23 '20 at 13:50
  • 2
    What is your use case? Based on the deprecation notice, you definitely shouldn't use `Send-MailMessage` to submit messages _over the internet_, but if you're sending via a local relay or an MTA in the same local network, then... meh, who cares :) – Mathias R. Jessen Oct 23 '20 at 14:07
  • No, for my use case I would be particularly concerned about security, hence the question. I should have made that more clear, sorry. – BroVic Oct 23 '20 at 14:10
  • 6
    You can easily find Powershell examples involving MailKit ( https://adamtheautomator.com/how-to-send-email-securely-with-powershell/ ) or you can use an existing module from Powershell Gallery that uses MailKit ( https://www.powershellgallery.com/packages/Send-MailKitMessage/ ). I make no claims about the quality or utility or appropriateness those examples. I'm merely showing that they're not hard to find. – Bacon Bits Oct 23 '20 at 14:42
  • Thank you @IanKemp for the useful generic solution. – BroVic Oct 23 '20 at 16:30
  • @BaconBits Thanks for showing me those. – BroVic Oct 23 '20 at 16:31

0 Answers0