Testare il login IMAP

Accede a una casella postale ed elenca le cartelle: verifica in un colpo solo raggiungibilità, credenziali e autorizzazioni.

IMAPS (993)

PowerShell (Windows)

SslStream (.NET) Integrato

$h = "mail.example.com"; $p = 993
$c = New-Object Net.Sockets.TcpClient($h, $p)
$ssl = New-Object Net.Security.SslStream($c.GetStream(), $false, ({ $true }))
$ssl.AuthenticateAsClient($h)
$r = New-Object IO.StreamReader($ssl)
$w = New-Object IO.StreamWriter($ssl); $w.NewLine = "`r`n"; $w.AutoFlush = $true
$r.ReadLine()
$w.WriteLine('a1 LOGIN user@example.com "P@ssw0rd"'); $r.ReadLine()
$w.WriteLine("a2 LIST \"\" *"); Start-Sleep -Milliseconds 400; while ($c.Available) { $r.ReadLine() }
$w.WriteLine("a3 LOGOUT"); $c.Close()

openssl Strumento aggiuntivo

openssl s_client -crlf -connect mail.example.com:993

Shell Unix (bash)

openssl Integrato

openssl s_client -crlf -quiet -connect mail.example.com:993 <<'EOF'
a1 LOGIN user@example.com "P@ssw0rd"
a2 LIST "" *
a3 LOGOUT
EOF

curl Strumento aggiuntivo

curl -v --url "imaps://mail.example.com:993" --user "user@example.com"

Microsoft 365

PowerShell (Windows)

SslStream (.NET) Integrato

$h = "outlook.office365.com"; $p = 993
$c = New-Object Net.Sockets.TcpClient($h, $p)
$ssl = New-Object Net.Security.SslStream($c.GetStream(), $false, ({ $true }))
$ssl.AuthenticateAsClient($h)
$r = New-Object IO.StreamReader($ssl)
$w = New-Object IO.StreamWriter($ssl); $w.NewLine = "`r`n"; $w.AutoFlush = $true
$r.ReadLine()
$w.WriteLine('a1 LOGIN user@contoso.com "P@ssw0rd"'); $r.ReadLine()
$w.WriteLine("a2 LIST \"\" *"); Start-Sleep -Milliseconds 400; while ($c.Available) { $r.ReadLine() }
$w.WriteLine("a3 LOGOUT"); $c.Close()

openssl Strumento aggiuntivo

openssl s_client -crlf -connect outlook.office365.com:993

Shell Unix (bash)

openssl Integrato

openssl s_client -crlf -quiet -connect outlook.office365.com:993 <<'EOF'
a1 LOGIN user@contoso.com "P@ssw0rd"
a2 LIST "" *
a3 LOGOUT
EOF

curl Strumento aggiuntivo

curl -v --url "imaps://outlook.office365.com:993" --user "user@contoso.com"

Sostituite P@ssw0rd con la password reale. Microsoft 365 ha disattivato l'autenticazione Basic per IMAP; lì serve OAuth 2.0, quindi un semplice tentativo LOGIN fallisce come previsto.

Funzionalità IMAP

Mostra le funzionalità annunciate dal server, inclusi i metodi di autenticazione supportati (AUTH=PLAIN, AUTH=XOAUTH2 ...).

IMAPS (993)

PowerShell (Windows)

SslStream (.NET) Integrato

$h = "mail.example.com"; $p = 993
$c = New-Object Net.Sockets.TcpClient($h, $p)
$ssl = New-Object Net.Security.SslStream($c.GetStream(), $false, ({ $true }))
$ssl.AuthenticateAsClient($h)
$r = New-Object IO.StreamReader($ssl)
$w = New-Object IO.StreamWriter($ssl); $w.NewLine = "`r`n"; $w.AutoFlush = $true
$r.ReadLine()
$w.WriteLine("a1 CAPABILITY"); Start-Sleep -Milliseconds 300; while ($c.Available) { $r.ReadLine() }
$w.WriteLine("a2 LOGOUT"); $c.Close()

openssl Strumento aggiuntivo

openssl s_client -crlf -connect mail.example.com:993

Shell Unix (bash)

openssl Integrato

printf 'a1 CAPABILITY\r\na2 LOGOUT\r\n' | openssl s_client -crlf -quiet -connect mail.example.com:993 2>/dev/null

curl Strumento aggiuntivo

curl -sv --url "imaps://mail.example.com:993" 2>&1 | grep -i capability

Stato della casella

Interroga il numero di messaggi e di messaggi non letti nella posta in arrivo: utile per confermare una consegna.

PowerShell (Windows)

SslStream (.NET) Integrato

$h = "mail.example.com"; $p = 993
$c = New-Object Net.Sockets.TcpClient($h, $p)
$ssl = New-Object Net.Security.SslStream($c.GetStream(), $false, ({ $true }))
$ssl.AuthenticateAsClient($h)
$r = New-Object IO.StreamReader($ssl)
$w = New-Object IO.StreamWriter($ssl); $w.NewLine = "`r`n"; $w.AutoFlush = $true
$r.ReadLine()
$w.WriteLine('a1 LOGIN user@example.com "P@ssw0rd"'); $r.ReadLine()
$w.WriteLine("a2 STATUS INBOX (MESSAGES UNSEEN)"); Start-Sleep -Milliseconds 400; while ($c.Available) { $r.ReadLine() }
$w.WriteLine("a3 LOGOUT"); $c.Close()

curl Strumento aggiuntivo

curl.exe -v --url "imaps://mail.example.com:993/INBOX" --user "user@example.com" --request "STATUS INBOX (MESSAGES UNSEEN)"

Shell Unix (bash)

openssl Integrato

openssl s_client -crlf -quiet -connect mail.example.com:993 <<'EOF'
a1 LOGIN user@example.com "P@ssw0rd"
a2 STATUS INBOX (MESSAGES UNSEEN)
a3 LOGOUT
EOF

curl Strumento aggiuntivo

curl --url "imaps://mail.example.com:993/INBOX" --user "user@example.com" --request "STATUS INBOX (MESSAGES UNSEEN)"

Sostituite P@ssw0rd con la password reale.

Testare POP3

Accede via POP3 e con STAT interroga numero e dimensione dei messaggi in attesa.

PowerShell (Windows)

SslStream (.NET) Integrato

$h = "mail.example.com"; $p = 995
$c = New-Object Net.Sockets.TcpClient($h, $p)
$ssl = New-Object Net.Security.SslStream($c.GetStream(), $false, ({ $true }))
$ssl.AuthenticateAsClient($h)
$r = New-Object IO.StreamReader($ssl)
$w = New-Object IO.StreamWriter($ssl); $w.NewLine = "`r`n"; $w.AutoFlush = $true
$r.ReadLine()
$w.WriteLine("USER user@example.com"); $r.ReadLine()
$w.WriteLine("PASS P@ssw0rd"); $r.ReadLine()
$w.WriteLine("STAT"); $r.ReadLine()
$w.WriteLine("QUIT"); $c.Close()

openssl Strumento aggiuntivo

openssl s_client -crlf -connect mail.example.com:995

Shell Unix (bash)

openssl Integrato

openssl s_client -crlf -quiet -connect mail.example.com:995 <<'EOF'
USER user@example.com
PASS P@ssw0rd
STAT
QUIT
EOF

curl Strumento aggiuntivo

curl -v --url "pop3s://mail.example.com:995" --user "user@example.com"

Sostituite P@ssw0rd con la password reale. A seconda del client, POP3 elimina i messaggi dopo il prelievo; un semplice test STAT no.

IMAP STARTTLS (143)

Stabilisce una connessione STARTTLS sulla porta in chiaro 143 e mostra il certificato.

PowerShell (Windows)

TcpClient (.NET) Integrato

$c = New-Object Net.Sockets.TcpClient("mail.example.com", 143)
$s = $c.GetStream()
$r = New-Object IO.StreamReader($s)
$w = New-Object IO.StreamWriter($s); $w.NewLine = "`r`n"; $w.AutoFlush = $true
$r.ReadLine()
$w.WriteLine("a1 STARTTLS"); $r.ReadLine()
$ssl = New-Object Net.Security.SslStream($s, $false, ({ $true }))
$ssl.AuthenticateAsClient("mail.example.com")
([Security.Cryptography.X509Certificates.X509Certificate2]$ssl.RemoteCertificate) | Format-List Subject, NotAfter
$ssl.Dispose(); $c.Close()

openssl Strumento aggiuntivo

openssl s_client -starttls imap -crlf -connect mail.example.com:143

Shell Unix (bash)

openssl Integrato

openssl s_client -starttls imap -connect mail.example.com:143 </dev/null 2>/dev/null | openssl x509 -noout -subject -issuer -dates

curl Strumento aggiuntivo

curl -v --url "imap://mail.example.com:143" --ssl-reqd

Altre aree