Cara Memeriksa Sambungan SMTP dengan Sesi Telnet Manual

Cara Memeriksa Sambungan SMTP dengan Sesi Telnet Manual

Cara Memeriksa Sambungan SMTP dengan Sesi Telnet Manual

Feb 7, 2020

Diterbitkan oleh

Diterbitkan oleh

Bird

Bird

Kategori:

Kategori:

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.

  • Apakah server sudah aktif?

  • Apakah ada firewall yang memblokir komunikasi?

  • Apakah server email mengizinkan penerusan domain/alamat email tertentu?

  • Perintah SMTP apa saja yang didukung oleh server email?

  • Apakah server merespons dengan nama host yang benar?

  • Apakah koneksi berfungsi di luar perangkat lunak atau API pihak ketiga?


Semua pertanyaan ini dan banyak lagi dapat dijawab dengan tes telnet sederhana.

Before we get started, be sure to open up our companion piece to this post: Ke Mana Pesan Bounce Dikirim? 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.


Bagaimana Cara Mengirim Email Menggunakan Telnet?

Mengirim email melalui telnet dapat membantu Anda mengidentifikasi masalah pengiriman dalam konfigurasi Anda saat ini.


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.

Setelah klien telnet diverifikasi untuk diinstal pada server, buka jendela terminal tempat Anda akan memasukkan perintah-perintah prompt. Pada Windows, gunakan tombol Windows + R, ketik "cmd", dan tekan enter. Untuk pengguna Mac, Anda akan menemukan ikon terminal dengan membuka Finder dan mencari "Utilities" pada halaman Aplikasi, atau dengan memasukkan "terminal" pada fungsi pencarian Launchpad.

Selanjutnya, kita perlu menemukan server email untuk masuk. Untuk itu, kita akan membutuhkan record DNS MX untuk domain tertentu. Ini dapat ditemukan dengan perintah berikut (untuk contoh ini port25.com akan digunakan, tetapi domain apa pun dapat diganti):

Windows:

nslookup -type = mx port25.com

Jawaban yang tidak otoritatif:

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

Linux:

nslookup -type = mx port25.com

Jawaban yang tidak otoritatif:

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


SMTP menggunakan salah satu dari tiga port - 25, 465, atau 587, yang biasanya digunakan oleh Microsoft Outlook. Jika relai SMTP Anda menggunakan port yang berbeda dari 25 seperti yang ditunjukkan pada contoh, Anda akan menggunakan port yang ditentukan oleh respons server pertukaran surat terhadap nslookup. Anda juga dapat memverifikasi port yang digunakan SMTP Anda dengan bertanya pada administrator atau masuk ke server pertukaran surat dan meninjau protokolnya.

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/


Dengan alamat IP, jalankan perintah berikut ini, di mana A.B.C.D adalah alamat IP.

Windows:

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

Non-authoritative answer: 

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

Linux:

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

Non-authoritative answer: 

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

server.example.com hanyalah sebuah contoh, dan hasil Anda akan berbeda.

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

telnet mail.port25.com 25

Sesuatu yang serupa dengan yang berikut ini seharusnya sekarang ditampilkan:

Mencoba 69.63.149.30... Tersambung ke mail.port25.com (69.63.149.30). Karakter escape adalah '^]'. 220 mail.port25.com (PowerMTA(TM) v4.0) Layanan ESMTP siap

Jika Anda menerima pesan kesalahan seperti "tidak dapat terhubung" pada saat ini, nomor port sudah benar atau server email menghadapi masalah.

The first command we need to issue ke  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

Sesuatu yang mirip dengan yang berikut ini harus dikembalikan:

250-mail.port25.com menyapa 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-UKURAN 41943040 250 PIPELINING

Dan aol hanya menunjukkan satu dengan:

250 DSN

The 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


Pastikan Anda menggunakan nama domain yang sesuai dengan domain server email Anda. Misalnya, jika domain email Anda adalah anycompany.com, Anda sebaiknya menggunakan you@anycompany.com, bukan email luar seperti you@free-mail-provider.com. Variasi nama domain dapat menyebabkan munculnya pesan kesalahan.


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

Periksa kembali alamat penerima Anda sebelum mengirim perintah RCPT TO - pesan kesalahan yang muncul di sini dapat mengindikasikan penerima email yang salah eja atau diblokir.

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 mengirim pesan

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

Dengan header yang sudah diatur, kita sekarang menambahkan satu baris kosong dengan carriage return/line feed (cukup tekan enter dua kali) dan kemudian kita memulai isi pesan yang sebenarnya.

Halo Dunia, Ini adalah pesan uji yang dikirim dari sesi telnet manual. Hormat kami, administrator 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

Jika Anda mendapatkan pesan kesalahan dan bukan notifikasi "diterima", catat detail yang relevan dan hubungi penyedia email Anda untuk bantuan lebih lanjut.

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

BERHENTI 221 2.0.0 mail.port25.com mengucapkan selamat tinggal

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

Berikut ini semua perintah tanpa gangguan:

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


Mengirim email menggunakan telnet memungkinkan Anda menguji kemampuan koneksi dengan cepat dan dengan biaya yang lebih murah daripada peralatan diagnostik atau perangkat lunak yang canggih.


Bagaimana Cara Menguji SMTP Menggunakan Otentikasi Telnet?

Sekarang setelah Anda mengetahui cara memeriksa koneksi SMTP dengan telnet, kita akan membahas prosedur autentikasi. Otentikasi SMTP membantu mencegah spam dalam jumlah besar mencapai kotak masuk pembaca, meskipun tidak semua server pertukaran surat memerlukannya.


Perbedaan utama dalam protokol autentikasi modern adalah adanya pengkodean base64. Base64 mengubah data biner menjadi format teks ASCII yang diperlukan oleh server email untuk transmisi data yang sukses. Ini adalah cara untuk merepresentasikan kredensial login Anda - beberapa kombinasi teks - dalam format numerik yang dapat dimengerti oleh komputer.

Anda dapat membuat base64 menggunakan perangkat lunak atau alat online gratis. Setelah Anda menyampaikan informasi ke server email, server akan membandingkan data ini dengan catatannya untuk menentukan autentikasi.


Untuk menguji autentikasi SMTP melalui telnet, selesaikan langkah-langkah berikut:

  • Buka terminal dan sambungkan dengan server mail menggunakan nama server telnet dan perintah akses - mail.port25.com pada contoh di atas.

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

  • Masukkan nama pengguna yang dikodekan dengan base64 dan izinkan server untuk menjawab.

  • Masukkan kata sandi yang dikodekan dalam base64, dan Anda akan menerima respons seperti "autentikasi berhasil."

  • Lanjutkan dengan MAIL FROM, RCPT TO, DATA, dan QUIT untuk mengirim email yang telah diautentikasi.

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

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

By clicking "See Bird" you agree to Bird's Pemberitahuan Privasi.

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

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

By clicking "See Bird" you agree to Bird's Pemberitahuan Privasi.