Add Obsolete message to Send-MailMessage (#9178)

Add Obsolete message to Send-MailMessage

## PR Context

See https://github.com/PowerShell/PowerShell-RFC/pull/160

Co-authored-by: Steve Lee <slee@microsoft.com>
Co-authored-by: Ilya <darpa@yandex.ru>
This commit is contained in:
Travis Plunk 2019-03-22 12:52:41 -07:00 committed by GitHub
parent f81f778308
commit 94616f1789
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View file

@ -14,6 +14,7 @@ namespace Microsoft.PowerShell.Commands
/// <summary>
/// Implementation for the Send-MailMessage command.
/// </summary>
[Obsolete("This cmdlet does not guarantee secure connections to SMTP servers. While there is no immediate replacement available in PowerShell, we recommend you do not use Send-MailMessage at this time. See https://aka.ms/SendMailMessage for more information.")]
[Cmdlet(VerbsCommunications.Send, "MailMessage", HelpUri = "https://go.microsoft.com/fwlink/?LinkID=135256")]
public sealed class SendMailMessage : PSCmdlet
{

View file

@ -78,7 +78,16 @@ Describe "Send-MailMessage" -Tags CI, RequireSudoOnUnix {
$server | Should -Not -Be $null
Send-MailMessage @InputObject -ErrorAction SilentlyContinue
$powershell = [PowerShell]::Create()
$null = $powershell.AddCommand("Send-MailMessage").AddParameters($InputObject).AddParameter("ErrorAction","SilentlyContinue")
$powershell.Invoke()
$warnings = $powershell.Streams.Warning
$warnings.count | Should -BeGreaterThan 0
$warnings[0].ToString() | Should -BeLike "The command 'Send-MailMessage' is obsolete. *"
$mail = Read-Mail