So überprüfen Sie eine SMTP-Verbindung mit einer manuellen Telnet-Sitzung

So überprüfen Sie eine SMTP-Verbindung mit einer manuellen Telnet-Sitzung

So überprüfen Sie eine SMTP-Verbindung mit einer manuellen Telnet-Sitzung

Feb 7, 2020

Herausgegeben von

Herausgegeben von

Bird

Bird

-

Kategorie:

Kategorie:

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.

  • Ist der Server in Betrieb?

  • Gibt es eine Firewall, die die Kommunikation blockiert?

  • Erlaubt der Mailserver das Relaying einer bestimmten Domäne/E-Mail-Adresse?

  • Welche SMTP-Befehle unterstützt der Mailserver?

  • Antwortet der Server mit dem richtigen Hostnamen?

  • Funktioniert die Verbindung auch außerhalb von Software oder APIs von Drittanbietern?


All diese Fragen und mehr können mit einem einfachen Telnet-Test beantwortet werden.

Before we get started, be sure to open up our companion piece to this post: Wohin werden Bounce-Nachrichten gesendet? 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.


Wie sende ich eine E-Mail über Telnet?

Das Versenden von E-Mails über Telnet kann Ihnen helfen, Zustellbarkeitsprobleme innerhalb Ihrer aktuellen Konfiguration zu erkennen.


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.

Sobald sichergestellt ist, dass ein Telnet-Client auf dem Server installiert ist, öffnen Sie das Terminalfenster, in das Sie Ihre Eingabeaufforderung eingeben. Unter Windows drücken Sie die Tastenkombination Windows + R, geben "cmd" ein und drücken die Eingabetaste. Mac-Benutzer finden das Terminal-Symbol, indem sie den Finder öffnen und auf der Seite "Programme" nach "Dienstprogramme" suchen oder "terminal" in die Suchfunktion des Launchpads eingeben.

Als nächstes müssen wir einen Mailserver finden, bei dem wir uns anmelden können. Dazu benötigen wir den DNS MX-Eintrag für eine bestimmte Domäne. Dieser kann mit dem folgenden Befehl ermittelt werden (für diese Beispiele wird port25.com verwendet, aber jede beliebige Domäne kann ersetzt werden):

Fenster:

nslookup -type=mx port25.com

Nicht-autoritative Antwort:

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

Linux:

nslookup -type=mx port25.com

Nicht-autoritative Antwort:

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


SMTP verwendet einen der drei Ports 25, 465 oder 587, die Microsoft Outlook in der Regel verwendet. Wenn Ihr SMTP-Relay einen anderen Port als 25 verwendet, wie im Beispiel gezeigt, verwenden Sie den Port, der in der Antwort des Mail-Exchange-Servers auf den nslookup angegeben ist. Sie können den Port, den Ihr SMTP verwendet, auch überprüfen, indem Sie Ihren Administrator fragen oder sich beim Mail Exchange Server anmelden und die Protokolle überprüfen.

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/


Führen Sie mit der IP-Adresse den folgenden Befehl aus, wobei A.B.C.D die IP-Adresse ist.

Fenster:

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

Non-authoritative answer: 

D.C.B.A.in-addr.arpa name = server.beispiel.com

Linux:

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

Non-authoritative answer: 

D.C.B.A.in-addr.arpa name = server.beispiel.com

server.example.com ist nur ein Beispiel, und Ihre Ergebnisse werden anders ausfallen.

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 zum SMTP server.  To do so, use the following command:

telnet mail.port25.com 25

Es sollte nun etwas Ähnliches wie das Folgende angezeigt werden:

Versucht 69.63.149.30... Verbunden mit mail.port25.com (69.63.149.30). Escape-Zeichen ist '^]'. 220 mail.port25.com (PowerMTA(TM) v4.0) ESMTP-Dienst bereit

Wenn Sie an dieser Stelle eine Fehlermeldung wie "cannot connect" erhalten, ist entweder die Portnummer korrekt oder der Mailserver hat Probleme.

Die first command we need to issue zum  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.beispiel.de

Es sollte etwas Ähnliches wie das Folgende zurückgegeben werden:

250-mail.port25.com lässt grüßen 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

Und aol zeigt nur einen mit an:

250 DSN

Die 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


Stellen Sie sicher, dass Sie den Domänennamen verwenden, der der Domäne Ihres Mailservers entspricht. Wenn die Domäne Ihres E-Mail-Servers beispielsweise anycompany.com lautet, müssen Sie you@anycompany.com anstelle einer externen E-Mail wie you@free-mail-provider.com verwenden. Abweichungen bei den Domänennamen können zu einer Fehlermeldung führen.


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

Überprüfen Sie die Adresse Ihres Empfängers, bevor Sie den Befehl RCPT TO senden - eine hier angezeigte Fehlermeldung kann auf einen falsch geschriebenen oder gesperrten E-Mail-Empfänger hinweisen.

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 Nachricht senden

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

Nachdem die Kopfzeilen gesetzt sind, fügen wir nun eine Leerzeile mit einem Wagenrücklauf/Zeilenvorschub ein (drücken Sie einfach zweimal die Eingabetaste) und beginnen dann mit dem eigentlichen Text der Nachricht.

Hallo Welt, Dies ist eine Testnachricht, die von einer manuellen Telnet-Sitzung gesendet wurde. Mit freundlichen Grüßen, SMTP-Administrator

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

Wenn Sie eine Fehlermeldung anstelle der Benachrichtigung "empfangen" erhalten, protokollieren Sie die entsprechenden Details und wenden Sie sich an Ihren E-Mail-Anbieter, um weitere Unterstützung zu erhalten.

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

QUIT 221 2.0.0 mail.port25.com sagt auf Wiedersehen

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 sind alle Befehle ohne Unterbrechung:

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


Durch das Senden einer E-Mail über Telnet können Sie die Verbindungsmöglichkeiten schnell und kostengünstig testen, ohne dass Sie dafür eine robuste Diagnoseausrüstung oder Software benötigen.


Wie kann ich SMTP mit Telnet-Authentifizierung testen?

Nachdem Sie nun wissen, wie Sie eine SMTP-Verbindung mit Telnet überprüfen können, werden wir nun die Authentifizierungsverfahren besprechen. Die SMTP-Authentifizierung hilft zu verhindern, dass große Mengen an Spam in die Postfächer der Leser gelangen, obwohl nicht alle Mail Exchange Server dies verlangen.


Der Hauptunterschied bei modernen Authentifizierungsprotokollen ist das Vorhandensein einer Base64-Kodierung. Base64 wandelt binäre Daten in das ASCII-Textformat um, das von Mailservern für eine erfolgreiche Datenübertragung benötigt wird. Es ist eine Möglichkeit, Ihre Anmeldedaten - eine Kombination aus Text - in einem numerischen Format darzustellen, das der Computer verstehen kann.

Sie können Ihre base64-Daten mithilfe von Software oder kostenlosen Online-Tools generieren. Sobald Sie die Informationen an den Mailserver übermitteln, vergleicht er diese Daten mit seinen Einträgen, um die Authentifizierung zu bestimmen.


Um die SMTP-Authentifizierung über Telnet zu testen, führen Sie die folgenden Schritte aus:

  • Öffnen Sie das Terminal und stellen Sie eine Verbindung mit dem Mailserver her, indem Sie den Telnet-Servernamen und den Zugriffsbefehl verwenden - im obigen Beispiel mail.port25.com.

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

  • Geben Sie den base64-kodierten Benutzernamen ein und lassen Sie den Server antworten.

  • Geben Sie das in base64 kodierte Passwort ein, und Sie sollten eine Antwort wie "Authentifizierung erfolgreich" erhalten.

  • Fahren Sie mit MAIL FROM, RCPT TO, DATA und QUIT fort, um Ihre authentifizierte E-Mail zu senden.

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

The right message -> to the right person -> am right time.

By clicking "See Bird" you agree to Bird's Hinweis zum Datenschutz.

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

The right message -> to the right person -> am right time.

By clicking "See Bird" you agree to Bird's Hinweis zum Datenschutz.