Comment vérifier une connexion SMTP avec une session manuelle Telnet ?

Comment vérifier une connexion SMTP avec une session manuelle Telnet ?

Comment vérifier une connexion SMTP avec une session manuelle Telnet ?

Feb 7, 2020

Publié par

Publié par

Bird

Bird

-

Catégorie :

Catégorie :

Courriel :

Courriel :

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.

  • Le serveur est en place ?

  • Y a-t-il un pare-feu qui bloque la communication ?

  • Le serveur de messagerie permet-il de relayer un domaine/une adresse électronique particulière ?

  • Quelles commandes SMTP le serveur de messagerie prend-il en charge ?

  • Le serveur répond-il avec le bon nom d'hôte ?

  • La connexion fonctionne-t-elle en dehors de tout logiciel ou API d'un tiers ?


Toutes ces questions et bien d'autres encore peuvent trouver une réponse dans un simple test telnet.

Before we get started, be sure to open up our companion piece to this post: À qui sont envoyés les messages de rebond ? 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.


Comment envoyer un courriel en utilisant Telnet ?

L'envoi de courrier électronique par telnet peut vous aider à identifier les problèmes de délivrabilité dans votre configuration actuelle.


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.

Une fois qu'il a été vérifié qu'un client telnet est installé sur le serveur, ouvrez la fenêtre du terminal où vous entrerez vos commandes rapides. Sous Windows, utilisez les touches Windows + R, tapez "cmd" et appuyez sur Entrée. Pour les utilisateurs de Mac, vous trouverez l'icône du terminal en ouvrant le Finder et en recherchant "Utilitaires" sur la page des applications, ou en entrant "terminal" dans la fonction de recherche du Launchpad.

Ensuite, nous devons trouver un serveur de messagerie auquel nous connecter. Pour cela, nous aurons besoin de l'enregistrement DNS MX pour un domaine donné. Ceci peut être trouvé avec la commande suivante (pour ces exemples, port25.com sera utilisé, mais n'importe quel domaine peut être substitué) :

Les fenêtres :

nslookup -type=mx port25.com

Réponse non officielle :

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

Linux :

nslookup -type=mx port25.com

Réponse non officielle :

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


Le SMTP utilise l'un des trois ports suivants : 25, 465 ou 587, que Microsoft Outlook utilise couramment. Si votre relais SMTP utilise un port différent de 25 comme indiqué dans l'exemple, vous utiliserez le port spécifié par la réponse du serveur d'échange de courrier à la nslookup. Vous pouvez également vérifier le port sur lequel repose votre SMTP en demandant à votre administrateur ou en vous connectant au serveur d'échange de courrier et en examinant les protocoles.

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/


Avec l'adresse IP, exécutez la commande suivante, où A.B.C.D est l'adresse IP.

Les fenêtres :

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

Non-authoritative answer: 

D.C.B.A.in-addr.arpa nom = serveur.exemple.com

Linux :

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

Non-authoritative answer: 

D.C.B.A.in-addr.arpa nom = serveur.exemple.com

server.example.com est juste un exemple, et vos résultats seront différents.

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

telnet mail.port25.com 25

Quelque chose de semblable à ce qui suit devrait maintenant s'afficher :

Essai sur 69.63.149.30... Connexion à mail.port25.com (69.63.149.30). Le caractère d'échappement est '^]'. 220 mail.port25.com (PowerMTA(TM) v4.0) ESMTP service ready

Si vous recevez un message d'erreur du type "impossible de se connecter" à ce stade, cela signifie que le numéro de port est correct ou que le serveur de messagerie rencontre des problèmes.

Le first command we need to issue à la  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

Quelque chose de similaire à ce qui suit devrait être renvoyé :

250-mail.port25.com dit bonjour 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

Et aol n'en montre qu'un seul avec :

250 DSN

Le 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


Veillez à utiliser le nom de domaine correspondant au domaine de votre serveur de messagerie. Par exemple, si le domaine de votre messagerie est anycompany.com, vous voudrez utiliser you@anycompany.com au lieu d'une messagerie externe comme you@free-mail-provider.com. Des variations dans les noms de domaine peuvent entraîner l'apparition d'un message d'erreur.


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

Vérifiez l'adresse de votre destinataire avant d'envoyer la commande RCPT TO - un message d'erreur s'affichant ici peut indiquer un destinataire mal orthographié ou bloqué.

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 envoyer un message

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

Une fois les en-têtes définis, nous ajoutons une ligne vierge avec un retour chariot/saut de ligne (il suffit d'appuyer deux fois sur la touche Entrée), puis nous commençons le corps du message.

Hello World, Ceci est un message de test envoyé depuis une session manuelle de telnet. Bien à vous, administrateur SMTP

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

Si vous obtenez un message d'erreur au lieu de la notification "reçu", enregistrez les détails pertinents et contactez votre fournisseur de messagerie pour plus d'assistance.

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

QUIT 221 2.0.0 mail.port25.com dit au revoir

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!!!

Voici toutes les commandes sans interruption :

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


L'envoi d'un courriel à l'aide de telnet vous permet de tester les capacités de connexion rapidement et à moindre coût qu'un équipement ou un logiciel de diagnostic robuste.


Comment tester le SMTP en utilisant l'authentification Telnet ?

Maintenant que vous savez comment vérifier une connexion SMTP avec telnet, nous allons aborder les procédures d'authentification. L'authentification SMTP permet d'empêcher de grandes quantités de spam d'atteindre les boîtes de réception des lecteurs, bien que tous les serveurs d'échange de courrier ne l'exigent pas.


La principale différence des protocoles d'authentification modernes est la présence d'un encodage base64. Base64 convertit les données binaires au format texte ASCII requis par les serveurs de messagerie pour une transmission réussie des données. C'est une façon de représenter vos informations d'identification - une combinaison de texte - dans un format numérique que l'ordinateur peut comprendre.

Vous pouvez générer votre base64 à l'aide d'un logiciel ou d'outils en ligne gratuits. Une fois que vous avez communiqué les informations au serveur de messagerie, celui-ci compare ces données avec ses enregistrements pour déterminer l'authentification.


Pour tester l'authentification SMTP via telnet, effectuez les étapes suivantes :

  • Ouvrez le terminal et connectez-vous au serveur de messagerie en utilisant le nom du serveur telnet et la commande d'accès - mail.port25.com dans l'exemple ci-dessus.

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

  • Saisissez le nom d'utilisateur codé en base64 et laissez le serveur répondre.

  • Saisissez le mot de passe codé en base64, et vous devriez recevoir une réponse du type "authentification réussie".

  • Procédez avec MAIL FROM, RCPT TO, DATA, et QUITTER pour envoyer votre email authentifié.

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

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

By clicking "See Bird" you agree to Bird's Avis de confidentialité.

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

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

By clicking "See Bird" you agree to Bird's Avis de confidentialité.