Cómo comprobar una conexión SMTP con una sesión Telnet manual

Cómo comprobar una conexión SMTP con una sesión Telnet manual

Cómo comprobar una conexión SMTP con una sesión Telnet manual

Feb 7, 2020

Publicado por

Publicado por

Bird

Bird

-

Categoría:

Categoría:

Email

Email

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.

  • ¿Está funcionando el servidor?

  • ¿Hay algún cortafuegos bloqueando la comunicación?

  • ¿Permite el servidor de correo la retransmisión de un determinado dominio/dirección de correo electrónico?

  • ¿Qué comandos SMTP admite el servidor de correo?

  • ¿Responde el servidor con el nombre de host correcto?

  • ¿Funciona la conexión al margen de cualquier software o API de terceros?


Todas estas preguntas y muchas más pueden responderse con una simple prueba telnet.

Before we get started, be sure to open up our companion piece to this post: ¿Adónde se envían los mensajes rebotados? 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.


¿Cómo envío un correo electrónico utilizando Telnet?

El envío de correo electrónico a través de telnet puede ayudarle a identificar problemas de entregabilidad en su configuración actual.


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.

Una vez comprobado que el cliente telnet está instalado en el servidor, abre la ventana del terminal donde introducirás tus comandos prompt. En Windows, utiliza Windows + R, teclea "cmd" y pulsa Intro. Los usuarios de Mac encontrarán el icono del terminal abriendo el Finder y buscando "Utilidades" en la página de Aplicaciones, o introduciendo "terminal" en la función de búsqueda del Launchpad.

A continuación, tenemos que encontrar un servidor de correo al que conectarnos. Para ello, necesitaremos el registro DNS MX de un dominio determinado. Esto se puede encontrar con el siguiente comando (para estos ejemplos se utilizará port25.com, pero cualquier dominio puede ser sustituido):

Ventanas:

nslookup -type=mx puerto25.com

Respuesta no autorizada:

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

Linux:

nslookup -type=mx puerto25.com

Respuesta no autorizada:

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


SMTP utiliza uno de estos tres puertos: 25, 465 o 587, que es el que suele utilizar Microsoft Outlook. Si tu relé SMTP utiliza un puerto distinto de 25, como se muestra en el ejemplo, utilizarás el puerto especificado por la respuesta del servidor de intercambio de correo al nslookup. También puedes verificar el puerto en el que se basa tu SMTP preguntando a tu administrador o accediendo al servidor de intercambio de correo y revisando los protocolos.

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/


Con la dirección IP ejecute el siguiente comando, donde A.B.C.D es la dirección IP.

Ventanas:

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

Non-authoritative answer: 

D.C.B.A.in-addr.arpa nombre = servidor.ejemplo.com

Linux:

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

Non-authoritative answer: 

D.C.B.A.in-addr.arpa nombre = servidor.ejemplo.com

servidor.ejemplo.com es sólo un ejemplo, y sus resultados serán diferentes.

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

telnet mail.port25.com 25

Ahora debería aparecer algo similar a lo siguiente:

Probando 69.63.149.30... Conectado a mail.port25.com (69.63.149.30). El carácter de escape es '^]'. 220 mail.port25.com (PowerMTA(TM) v4.0) Servicio ESMTP listo

Si recibe un mensaje de error como "no se puede conectar" en este punto, o bien el número de puerto es correcto o el servidor de correo tiene problemas.

En first command we need to issue a 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 servidor.ejemplo.com

Debería devolverse algo similar a lo siguiente:

250-mail.port25.com dice hola 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

Y aol solo muestra uno con:

250 DSN

En 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


Asegúrate de utilizar el nombre de dominio correspondiente al dominio de tu servidor de correo. Por ejemplo, si el dominio de tu correo es anycompany.com, deberás utilizar you@anycompany.com en lugar de un correo externo como you@free-mail-provider.com. Las variaciones en los nombres de dominio pueden provocar la aparición de un mensaje de error.


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

Compruebe dos veces la dirección del destinatario antes de enviar el comando RCPT TO: un mensaje de error que aparezca aquí puede indicar un destinatario de correo electrónico mal escrito o bloqueado.

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 enviar mensaje

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

Con las cabeceras configuradas, ahora añadimos una línea en blanco con un retorno de carro/salto de línea (basta con pulsar Intro dos veces) y luego empezamos el cuerpo real del mensaje.

Hola Mundo, Este es un mensaje de prueba enviado desde una sesión telnet manual. Atentamente, administrador 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 recibes un mensaje de error en lugar de la notificación de "recibido", registra los detalles pertinentes y ponte en contacto con tu proveedor de correo electrónico para obtener más ayuda.

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

QUIT 221 2.0.0 mail.port25.com dice adiós

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

Aquí están todos los comandos sin interrupción:

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


El envío de un correo electrónico mediante telnet permite probar las capacidades de conexión con rapidez y a un coste inferior al de un equipo o software de diagnóstico robusto.


¿Cómo pruebo SMTP usando autenticación Telnet?

Ahora que ya sabes cómo comprobar una conexión SMTP con telnet, hablaremos de los procedimientos de autenticación. La autenticación SMTP ayuda a evitar que grandes cantidades de spam lleguen a las bandejas de entrada de los lectores, aunque no todos los servidores de intercambio de correo la requieren.


La principal diferencia en los protocolos de autenticación modernos es la presencia de una codificación base64. Base64 convierte los datos binarios en el formato de texto ASCII que necesitan los servidores de correo para transmitir los datos correctamente. Es una forma de representar tus credenciales de acceso -una combinación de texto- en un formato numérico que el ordenador pueda entender.

Puede generar su base64 utilizando software o herramientas gratuitas en línea. Una vez que comunique la información al servidor de correo, éste comparará estos datos con sus registros para determinar la autenticación.


Para probar la autenticación SMTP a través de telnet, complete los siguientes pasos:

  • Abra el terminal y conéctese con el servidor de correo utilizando el nombre del servidor telnet y el comando de acceso - mail.port25.com en el ejemplo anterior.

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

  • Introduzca el nombre de usuario codificado en base64 y permita que el servidor responda.

  • Introduce la contraseña codificada en base64, y deberías recibir una respuesta como "autenticación correcta".

  • Proceda con MAIL FROM, RCPT TO, DATA y QUIT para enviar su correo electrónico autenticado.

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

The right message -> to the right person -> en el right time.

By clicking "See Bird" you agree to Bird's Confidencialidad.

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

The right message -> to the right person -> en el right time.

By clicking "See Bird" you agree to Bird's Confidencialidad.