SMTP-tester
Tilgjengelighet, banner, STARTTLS og testmelding.
Er porten tilgjengelig?
Kontrollerer om SMTP-porten (25, 587 eller 465) er åpen fra der du er nå.
SMTP (25)
- Vert / server
-
mail.example.comEndre i generatoren →
PowerShell (Windows)
Test-NetConnection Innebygd
Test-NetConnection -ComputerName mail.example.com -Port 25 nc / ncat Tilleggsverktøy
ncat -vz mail.example.com 25 Unix-skall (bash)
bash /dev/tcp Innebygd
timeout 5 bash -c "</dev/tcp/mail.example.com/25" && echo open || echo closed nc Tilleggsverktøy
nc -vz mail.example.com 25 Submission (587)
- Vert / server
-
mail.example.comEndre i generatoren →
PowerShell (Windows)
Test-NetConnection Innebygd
Test-NetConnection -ComputerName mail.example.com -Port 587 nc / ncat Tilleggsverktøy
ncat -vz mail.example.com 587 Unix-skall (bash)
bash /dev/tcp Innebygd
timeout 5 bash -c "</dev/tcp/mail.example.com/587" && echo open || echo closed nc Tilleggsverktøy
nc -vz mail.example.com 587 SMTPS (465)
- Vert / server
-
mail.example.comEndre i generatoren →
PowerShell (Windows)
Test-NetConnection Innebygd
Test-NetConnection -ComputerName mail.example.com -Port 465 nc / ncat Tilleggsverktøy
ncat -vz mail.example.com 465 Unix-skall (bash)
bash /dev/tcp Innebygd
timeout 5 bash -c "</dev/tcp/mail.example.com/465" && echo open || echo closed nc Tilleggsverktøy
nc -vz mail.example.com 465 Banner + EHLO
Åpner tilkoblingen, leser 220-banneret og EHLO-svaret med de tilbudte funksjonene.
Eigener Mailserver
- Vert / server
-
mail.example.comEndre i generatoren →
PowerShell (Windows)
TcpClient (.NET) Innebygd
$h = "mail.example.com"; $p = 25
$c = New-Object Net.Sockets.TcpClient($h, $p)
$s = $c.GetStream()
$r = New-Object IO.StreamReader($s)
$w = New-Object IO.StreamWriter($s); $w.NewLine = "`r`n"; $w.AutoFlush = $true
Start-Sleep -Milliseconds 400; while ($c.Available) { $r.ReadLine() }
$w.WriteLine("EHLO test.example.com")
Start-Sleep -Milliseconds 400; while ($c.Available) { $r.ReadLine() }
$w.WriteLine("QUIT"); $c.Close() nc / ncat Tilleggsverktøy
"EHLO test.example.com`r`nQUIT`r`n" | ncat mail.example.com 25 Unix-skall (bash)
bash /dev/tcp Innebygd
exec 3<>/dev/tcp/mail.example.com/25
printf 'EHLO test.example.com\r\nQUIT\r\n' >&3
cat <&3
exec 3<&- nc Tilleggsverktøy
( printf 'EHLO test.example.com\r\nQUIT\r\n'; sleep 1 ) | nc mail.example.com 25 Microsoft 365
PowerShell (Windows)
TcpClient (.NET) Innebygd
$h = "contoso-com.mail.protection.outlook.com"; $p = 25
$c = New-Object Net.Sockets.TcpClient($h, $p)
$s = $c.GetStream()
$r = New-Object IO.StreamReader($s)
$w = New-Object IO.StreamWriter($s); $w.NewLine = "`r`n"; $w.AutoFlush = $true
Start-Sleep -Milliseconds 400; while ($c.Available) { $r.ReadLine() }
$w.WriteLine("EHLO test.example.com")
Start-Sleep -Milliseconds 400; while ($c.Available) { $r.ReadLine() }
$w.WriteLine("QUIT"); $c.Close() nc / ncat Tilleggsverktøy
"EHLO test.example.com`r`nQUIT`r`n" | ncat contoso-com.mail.protection.outlook.com 25 Unix-skall (bash)
bash /dev/tcp Innebygd
exec 3<>/dev/tcp/contoso-com.mail.protection.outlook.com/25
printf 'EHLO test.example.com\r\nQUIT\r\n' >&3
cat <&3
exec 3<&- nc Tilleggsverktøy
( printf 'EHLO test.example.com\r\nQUIT\r\n'; sleep 1 ) | nc contoso-com.mail.protection.outlook.com 25 Test STARTTLS
Oppretter en STARTTLS-tilkobling og viser sertifikatet.
Submission (587)
- Vert / server
-
mail.example.comEndre i generatoren →
PowerShell (Windows)
SslStream (.NET) Innebygd
$h = "mail.example.com"; $p = 587
$c = New-Object Net.Sockets.TcpClient($h, $p)
$s = $c.GetStream()
$r = New-Object IO.StreamReader($s)
$w = New-Object IO.StreamWriter($s); $w.NewLine = "`r`n"; $w.AutoFlush = $true
$r.ReadLine() | Out-Null
$w.WriteLine("EHLO test.example.com"); Start-Sleep -Milliseconds 200; while ($c.Available) { $r.ReadLine() | Out-Null }
$w.WriteLine("STARTTLS"); $r.ReadLine()
$ssl = New-Object Net.Security.SslStream($s, $false, ({ $true }))
$ssl.AuthenticateAsClient($h)
([Security.Cryptography.X509Certificates.X509Certificate2]$ssl.RemoteCertificate) | Format-List Subject, Issuer, NotBefore, NotAfter
$ssl.Dispose(); $c.Close() openssl Tilleggsverktøy
openssl s_client -starttls smtp -crlf -connect mail.example.com:587 -servername mail.example.com Unix-skall (bash)
openssl Innebygd
openssl s_client -starttls smtp -connect mail.example.com:587 -servername mail.example.com </dev/null 2>/dev/null | openssl x509 -noout -subject -issuer -dates swaks Tilleggsverktøy
swaks --server mail.example.com:587 -tls --quit-after TLS Microsoft 365
- Vert / server
-
smtp.office365.comEndre i generatoren →
PowerShell (Windows)
SslStream (.NET) Innebygd
$h = "smtp.office365.com"; $p = 587
$c = New-Object Net.Sockets.TcpClient($h, $p)
$s = $c.GetStream()
$r = New-Object IO.StreamReader($s)
$w = New-Object IO.StreamWriter($s); $w.NewLine = "`r`n"; $w.AutoFlush = $true
$r.ReadLine() | Out-Null
$w.WriteLine("EHLO test.example.com"); Start-Sleep -Milliseconds 200; while ($c.Available) { $r.ReadLine() | Out-Null }
$w.WriteLine("STARTTLS"); $r.ReadLine()
$ssl = New-Object Net.Security.SslStream($s, $false, ({ $true }))
$ssl.AuthenticateAsClient($h)
([Security.Cryptography.X509Certificates.X509Certificate2]$ssl.RemoteCertificate) | Format-List Subject, Issuer, NotBefore, NotAfter
$ssl.Dispose(); $c.Close() openssl Tilleggsverktøy
openssl s_client -starttls smtp -crlf -connect smtp.office365.com:587 -servername smtp.office365.com Unix-skall (bash)
openssl Innebygd
openssl s_client -starttls smtp -connect smtp.office365.com:587 -servername smtp.office365.com </dev/null 2>/dev/null | openssl x509 -noout -subject -issuer -dates swaks Tilleggsverktøy
swaks --server smtp.office365.com:587 -tls --quit-after TLS Deretter kan du fortsette å skrive manuelt (EHLO, så QUIT). openssl er et tilleggsverktøy, tilgjengelig i Windows f.eks. via Git for Windows, og fungerer også i PowerShell.
Implisitt TLS (465)
Kobler til med TLS med en gang på port 465 (SMTPS, implisitt TLS).
Impliztes TLS (465)
- Vert / server
-
mail.example.comEndre i generatoren →
PowerShell (Windows)
SslStream (.NET) Innebygd
$h = "mail.example.com"; $p = 465
$c = New-Object Net.Sockets.TcpClient($h, $p)
$ssl = New-Object Net.Security.SslStream($c.GetStream(), $false, ({ $true }))
$ssl.AuthenticateAsClient($h)
([Security.Cryptography.X509Certificates.X509Certificate2]$ssl.RemoteCertificate) | Format-List Subject, Issuer, NotAfter
$ssl.Dispose(); $c.Close() openssl Tilleggsverktøy
openssl s_client -connect mail.example.com:465 -servername mail.example.com Unix-skall (bash)
openssl Innebygd
openssl s_client -connect mail.example.com:465 -servername mail.example.com </dev/null 2>/dev/null | openssl x509 -noout -subject -issuer -dates swaks Tilleggsverktøy
swaks --server mail.example.com -p 465 --tlsc --quit-after BANNER Send testmelding (SMTP-strøm)
Bygger hele SMTP-dialogen linje for linje (EHLO, MAIL FROM, RCPT TO, DATA, QUIT) og sender en ekte testmelding: med innebygde verktøy, uten tilleggsverktøy.
- Vert / server
-
mail.example.comEndre i generatoren →
PowerShell (Windows)
TcpClient (.NET) Innebygd
$h = "mail.example.com"; $p = 25
$from = "sender@example.com"; $to = "recipient@example.com"
$c = New-Object Net.Sockets.TcpClient($h, $p)
$s = $c.GetStream()
$r = New-Object IO.StreamReader($s)
$w = New-Object IO.StreamWriter($s); $w.NewLine = "`r`n"; $w.AutoFlush = $true
function Talk($line) { if ($line) { $w.WriteLine($line) }; Start-Sleep -Milliseconds 300; while ($c.Available) { $r.ReadLine() } }
Talk $null
Talk "EHLO test.example.com"
Talk "MAIL FROM:<$from>"
Talk "RCPT TO:<$to>"
Talk "DATA"
$w.WriteLine("Subject: SMTP-Test")
$w.WriteLine("From: $from")
$w.WriteLine("To: $to")
$w.WriteLine("")
$w.WriteLine("Testnachricht via reinem SMTP-Stream.")
Talk "."
Talk "QUIT"
$c.Close() Send-MailMessage Tilleggsverktøy
Send-MailMessage -SmtpServer mail.example.com -Port 25 -From sender@example.com -To recipient@example.com -Subject "SMTP-Test" -Body "SMTP-Test $(Get-Date -Format o)" Unix-skall (bash)
bash /dev/tcp Innebygd
exec 3<>/dev/tcp/mail.example.com/25
send() { printf '%s\r\n' "$1" >&3; }
resp() { while IFS= read -r -t 3 line <&3; do printf '%s\n' "$line"; case $line in [0-9][0-9][0-9]" "*) break;; esac; done; }
resp
send "EHLO test.example.com"; resp
send "MAIL FROM:<sender@example.com>"; resp
send "RCPT TO:<recipient@example.com>"; resp
send "DATA"; resp
send "Subject: SMTP-Test"
send "From: sender@example.com"
send "To: recipient@example.com"
send ""
send "Testnachricht via reinem SMTP-Stream."
send "."; resp
send "QUIT"; resp
exec 3<&- swaks Tilleggsverktøy
swaks --server mail.example.com:25 --from sender@example.com --to recipient@example.com Den rå strømmen går ukryptert på port 25, egnet for et relé eller MX uten autentisering. For port 587 med STARTTLS og AUTH, bruk swaks eller openssl. Send-MailMessage er offisielt foreldet, men fungerer fortsatt.