Een SMTP-verbinding controleren met een handmatige Telnet-sessie

Een SMTP-verbinding controleren met een handmatige Telnet-sessie

Een SMTP-verbinding controleren met een handmatige Telnet-sessie

Feb 7, 2020

Gepubliceerd door

Gepubliceerd door

Bird

Bird

-

Categorie:

Categorie:

E-mail

E-mail

Ready to see Bird
in action?

Ready to see Bird
in action?

How to Check an SMTP Connection with a Manual Telnet Session

In the world of email, there are many facets to testing, but one of the most basic tests you can do is to simply telnet into a given SMTP server.  This SMTP check is useful in determining if the most basic of problems do or do not exist.

  • Staat de server aan?

  • Is er een firewall die de communicatie blokkeert?

  • Staat de mailserver relaying van een bepaald domein/e-mailadres toe?

  • Welke SMTP-commando's ondersteunt de mailserver?

  • Reageert de server met de juiste hostnaam?

  • Werkt de verbinding buiten software van derden of API's om?


Al deze vragen en meer kunnen worden beantwoord met een eenvoudige telnet-test.

Before we get started, be sure to open up our companion piece to this post: Waarheen worden stuiterberichten gestuurd? in a new tab so you can read it after you’re done with this blog.

As a note, the commands used in the following examples (as well as additional commands) are covered in section 4.1 of RFC 2821.


Hoe verstuur ik een e-mail met Telnet?

Het versturen van e-mail via telnet kan u helpen bij het identificeren van deliverabilityproblemen binnen uw huidige configuratie.


Before you send an email using telnet, confirm telnet is both installed and enabled on your computer. Most computers come pre-installed with a telnet client. For those Windows versions that do not, one can be installed by opening the “Programs and Features” section of the control panel and selecting “Turn Windows features on or off”. With this window open, select “telnet client” and then click OK.

Zodra is vastgesteld dat er een telnetclient op de server is geïnstalleerd, opent u het terminalvenster waarin u uw promptcommando's invoert. In Windows gebruikt u Windows + R, voert u "cmd" in en drukt u op enter. Mac-gebruikers vinden het terminalpictogram door de Finder te openen en te zoeken naar "Utilities" op de pagina Toepassingen, of door "terminal" in te voeren in de zoekfunctie van Launchpad.

Vervolgens moeten we een mailserver vinden waarop we kunnen inloggen. Hiervoor hebben we het DNS MX record voor een bepaald domein nodig. Dit kan worden gevonden met het volgende commando (in deze voorbeelden wordt port25.com gebruikt, maar elk domein kan worden vervangen):

Windows:

nslookup -type=mx port25.com

Niet gezaghebbend antwoord:

port25.com  MX preference = 100, mail exchanger = mail.port25.com

Linux:

nslookup -type=mx port25.com

Niet gezaghebbend antwoord:

port25.com  mail exchanger = 100 mail.port25.com.


SMTP gebruikt een van de drie poorten - 25, 465 of 587, die Microsoft Outlook gewoonlijk gebruikt. Als uw SMTP-relais een andere poort dan 25 gebruikt, zoals in het voorbeeld, gebruikt u de poort die is opgegeven in het antwoord van de mail exchange server op de nslookup. U kunt ook controleren op welke poort uw SMTP vertrouwt door uw beheerder te vragen of door in te loggen op de mail exchange server en de protocollen te bekijken.

Next we need the DNS PTR for the IP we are going to use.  First we need to know what IP address the internet sees us as having.  To find that we can use a website like:

http://whatismyipaddress.com/


Voer met het IP-adres het volgende commando uit, waarbij A.B.C.D het IP-adres is.

Windows:

nslookup -type=ptr A.B.C.D

Non-authoritative answer: 

D.C.B.A.in-addr.arpa naam = server.example.com

Linux:

nslookup -type=ptr A.B.C.D

Non-authoritative answer: 

D.C.B.A.in-addr.arpa naam = server.example.com

server.example.com is slechts een voorbeeld, en uw resultaten zullen anders zijn.

So now that we have the MX record for port25.com and the PTR for the IP we are going to use, it is time to log in naar de SMTP server.  To do so, use the following command:

telnet mail.port25.com 25

Er zou nu iets als het volgende moeten verschijnen:

Ik probeer 69.63.149.30... Verbonden met mail.port25.com (69.63.149.30). Escape karakter is '^]'. 220 mail.port25.com (PowerMTA(TM) v4.0) ESMTP service gereed

Als u op dit punt een foutmelding krijgt als "kan geen verbinding maken", is ofwel het poortnummer correct, ofwel heeft de mailserver problemen.

De first command we need to issue naar de  mail server for our SMTP email tester is the EHLO  or HELO.  This is a basic greeting that starts the communication between the telnet client and the SMTP server.  Also passed is the DNS PTR for the IP address from which we are connecting as determined previously.

EHLO server.example.com

Iets als het volgende moet worden teruggestuurd:

250-mail.port25.com zegt hallo 250-STARTTLS 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-CHUNKING 250-8BITMIME 250-XACK 250-XMRG 250-SIZE 54525952 250-VERP 250 DSN

This shows the SMTP commands that the SMTP server accepts.  Not all SMTP servers support the same sets of commands. For example, yahoo only shows the following:

250-8BITMIME 250-SIZE 41943040 250 PIPELINING

En aol laat er maar één zien met:

250 DSN

De next command we need to issue is the MAIL FROM command.  This determines the address to which bounces are sent. This is not the same as the from header, which is the email address shown in an email client.

MAIL FROM: <support@port25.com> 250 2.1.0 MAIL ok


Zorg ervoor dat u de domeinnaam gebruikt die overeenkomt met het domein van uw mailserver. Als het domein van uw e-mail bijvoorbeeld anycompany.com is, wilt u you@anycompany.com gebruiken in plaats van een externe e-mail zoals you@free-mail-provider.com. Variaties in domeinnamen kunnen een foutmelding veroorzaken.


Now that the MAIL FROM  command has been sent we can send the RCPT TO  command.  This command tells the SMTP mail server to who the message should be sent. This can be the same or different than the to header, which is the email address shown in the email client.


RCPT TO: <support@port25.com> 250 2.1.5 <support@port25.com> ok

Controleer het adres van uw ontvanger dubbel voordat u de opdracht RCPT TO verstuurt - een foutmelding die hier verschijnt kan wijzen op een verkeerd gespelde of geblokkeerde e-mailontvanger.

The last command to run before starting the body of the message is the DATA  command.  This command lets the SMTP mail server know that everything else about to be sent is the body of the message (which also contains the headers).


DATA 354 bericht verzenden

It is important to note that if a mail server supports PIPELINING, as mail.port25.com does, the SMTP mail server may wait until the DATA command is issued before responding to any other commands after the EHLO/HELO.  In this case, enter the MAIL FROM, RCPT TO, and DATA  commands before waiting for a response.


Now that the DATA command has been sent we can start sending the message contents.  This starts with the various headers. At minimum a message should contain a to, from, subject, and date header. The headers entered here will be shown to the user in their email client.


From: "John Smith" <jsmith@port25.com> To: "Jane Doe" <jdoe@port25.com> Subject: test message sent from manual telnet session Date: Wed, 11 May 2011 16:19:57 -0400

Met de headers ingesteld, voegen we nu een lege regel toe met een carriage return/line feed (gewoon twee keer op enter drukken) en dan beginnen we het eigenlijke bericht.

Hallo Wereld, Dit is een testbericht verzonden vanuit een handmatige telnet-sessie. Hoogachtend, SMTP beheerder

With the message complete, we need to tell the SMTP server that we are done with the message and want the SMTP mail server to accept it.  This is done with a period on a line by itself. If during the writing of a message a period on a line by itself is needed, you must put 2 periods, the first escaping the second.


.   250 2.6.0 message received

Als u een foutmelding krijgt in plaats van de "ontvangen" melding, registreer dan de relevante gegevens en neem contact op met uw e-mailprovider voor meer hulp.

Lastly, the QUIT  command is sent to close the connection:

QUIT 221 2.0.0 mail.port25.com zegt vaarwel

With that the mail server has now accepted the message for delivery, your telnet send email test is complete, and it should be sitting in the inbox of the RCPT TO address!!!

Hier zijn alle commando's zonder onderbreking:

telnet mail.port25.com 25 Trying 69.63.149.30... Connected to mail.port25.com (69.63.149.30). Escape character is '^]'. 220 mail.port25.com (PowerMTA(TM) v4.0) ESMTP service ready EHLO server.example.com 250-mail.port25.com says hello 250-STARTTLS 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-CHUNKING 250-8BITMIME 250-XACK 250-XMRG 250-SIZE 54525952 250-VERP 250 DSN MAIL FROM: <support@port25.com> 250 2.1.0 MAIL ok RCPT TO: <support@port25.com> 250 2.1.5 <support@port25.com> ok DATA 354 send message From: "John Smith" <jsmith@port25.com> To: "Jane Doe" <jdoe@port25.com> Subject: test message sent from manual telnet session Date: Wed, 11 May 2011 16:19:57 -0400 Hello World, This is a test message sent from a manual telnet session. Yours truly, SMTP administrator . 250 2.6.0 message received QUIT 221 2.0.0 mail.port25.com says goodbye


Door een e-mail te sturen via telnet kunt u snel en goedkoper verbindingsmogelijkheden testen dan met robuuste diagnoseapparatuur of software.


Hoe test ik SMTP met Telnet Authenticatie?

Nu u weet hoe u een SMTP-verbinding met telnet kunt controleren, gaan we het hebben over verificatieprocedures. SMTP-authenticatie helpt voorkomen dat grote hoeveelheden spam de inbox van lezers bereiken, hoewel niet alle mail exchange servers dit vereisen.


Het belangrijkste verschil in moderne authenticatieprotocollen is de aanwezigheid van een base64-codering. Base64 zet binaire gegevens om in het ASCII-tekstformaat dat mailservers nodig hebben voor succesvolle gegevensoverdracht. Het is een manier om uw aanmeldingsgegevens - een combinatie van tekst - weer te geven in een numeriek formaat dat de computer kan begrijpen.

U kunt uw base64 genereren met behulp van software of gratis online tools. Zodra u de informatie aan de mailserver doorgeeft, vergelijkt hij deze gegevens met zijn records om de authenticatie te bepalen.


Voer de volgende stappen uit om de SMTP-authenticatie via telnet te testen:

  • Open de terminal en maak verbinding met de mailserver met de telnet-servernaam en het toegangscommando - mail.port25.com in het bovenstaande voorbeeld.

  • Greet the server with EHLO or HELO, enter AUTH LOGIN, and wait for the computer’s response.

  • Voer de base64-gecodeerde gebruikersnaam in en laat de server antwoorden.

  • Voer het wachtwoord gecodeerd in base64 in, en u zou een antwoord moeten krijgen zoals "authenticatie geslaagd".

  • Ga verder met MAIL FROM, RCPT TO, DATA en QUIT om uw geauthenticeerde e-mail te verzenden.

Your new standard in Marketing, Pay & Sales. It's Bird

The right message -> to the right person -> aan de right time.

Your new standard in Marketing, Pay & Sales. It's Bird

The right message -> to the right person -> aan de right time.