PowerShell test script for Raw SMTP diagnostic.
SMTP send diagnostic - implicit TLS (port 465) or STARTTLS (port 587), with authentication.
Uses raw TcpClient + SslStream. Send-MailMessage / System.Net.Mail.SmtpClient are not used:
they are obsolete and cannot do implicit TLS on port 465.
Logs each stage: DNS, TCP, TLS (protocol, cipher, certificate), full SMTP dialog (credentials masked),
AUTH, MAIL/RCPT/DATA. On failure reports the failed stage plus a likely cause.
.\Test-SmtpSend.ps1 -SmtpServer smtp.example.com -Port 465 -From test@example.com -To admin@example.com
$cred = Get-Credential
.\Test-SmtpSend.ps1 -SmtpServer smtp.example.com -Port 587 -From test@example.com -To admin@example.com -Credential $cred -LogPath .\smtp-test.log