Created
January 24, 2020 11:14
-
-
Save yskszk63/9337fa50ac51829e8c155874762a2f3e to your computer and use it in GitHub Desktop.
Hello StartTLS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
220 SG ESMTP service ready at ismtpd0008p1hnd1.sendgrid.net | |
[EHLO] | |
250-smtp.sendgrid.net | |
250-8BITMIME | |
250-PIPELINING | |
250-SIZE 31457280 | |
250-STARTTLS | |
250-AUTH PLAIN LOGIN | |
250 AUTH=PLAIN LOGIN | |
[STARTTLS] | |
220 Begin TLS negotiation now | |
[Upgrade socket] | |
[EHLO (tls)] | |
250-smtp.sendgrid.net | |
250-8BITMIME | |
250-PIPELINING | |
250-SIZE 31457280 | |
250-STARTTLS | |
250-AUTH PLAIN LOGIN | |
250 AUTH=PLAIN LOGIN | |
[QUIT (tls)] | |
221 See you later |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$sock = [Net.Sockets.TcpClient]::new('smtp.sendgrid.net', 587) | |
$tx = [Io.StreamWriter]::new($sock.GetStream()) | |
$rx = [Io.StreamReader]::new($sock.GetStream()) | |
$tx.AutoFlush = $true | |
$rx.ReadLine() | |
"" | |
"[EHLO]" | |
$tx.WriteLine('EHLO smtp.sendgrid.net') | |
do { | |
$r = $rx.ReadLine() | |
$r | |
} while ($r[3] -eq '-') | |
"" | |
"[STARTTLS]" | |
$tx.WriteLine('STARTTLS') | |
$rx.ReadLine() | |
"" | |
"[Upgrade socket]" | |
$ssl = [Net.Security.SslStream]::new($sock.GetStream(), $false, $null, $null) | |
$ssl.AuthenticateAsClient('smtp.sendgrid.net') | |
$tx = [Io.StreamWriter]::new($ssl) | |
$rx = [Io.StreamReader]::new($ssl) | |
$tx.AutoFlush = $true | |
"" | |
"[EHLO (tls)]" | |
$tx.WriteLine('EHLO smtp.sendgrid.net') | |
do { | |
$r = $rx.ReadLine() | |
$r | |
} while ($r[3] -eq '-') | |
"" | |
"[QUIT (tls)]" | |
$tx.WriteLine('QUIT') | |
$rx.ReadLine() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment