{"id":5093,"date":"2022-08-13T03:39:34","date_gmt":"2022-08-13T03:39:34","guid":{"rendered":"https:\/\/softov.com.br\/blog\/?p=5093"},"modified":"2022-08-13T03:39:34","modified_gmt":"2022-08-13T03:39:34","slug":"smtp-telnet-or-openssl","status":"publish","type":"post","link":"https:\/\/softov.com.br\/blog\/2022\/08\/13\/smtp-telnet-or-openssl\/","title":{"rendered":"SMTP &#8211; Telnet or OpenSSL"},"content":{"rendered":"\n<p>One day I was creating a SMTP client and faced some issues or poor documentation about how to simple send a e-mail using a command line tool, to be able to test the server and compare the results with my code to minify the problems.<\/p>\n\n\n\n<p>Most of the protocols like SMTP, HTTP are simple TCP clients, in some cases with SSL, to connect i normally use &#8216;telnet&#8217;, and with SSL I  use &#8216;openssl&#8217;.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Requirements<\/h2>\n\n\n\n<p>To use &#8216;telnet&#8217; or &#8216;openssl&#8217;, both need to be installed. In some distros like Linux or FreeBSD they come installed.<\/p>\n\n\n\n<p>To install then manually<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo apt-get install telnet openssl\r\n# or \r\n$ sudo yum install telnet openssl\n# FreeBSD\n$ pkg install telnet openssl\n# MACOS - Homebrew\n$ brew install telnet openssl<\/code><\/pre>\n\n\n\n<p> <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Connection<\/h2>\n\n\n\n<p>Most servers use port 25, 465 and 587.<br>Port 25 &#8211; Plain<br>Port 465 &#8211; SSL<br>Port 587 &#8211; SSL\/TLS<br><br>To connect to the server using telnet<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># telnet {host} {port}\n$ telnet smtp.domain.com 25<\/code><\/pre>\n\n\n\n<p>To connect using openssl<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># SSL\n$ openssl s_client -connect smtp.domain.com:465\n# SSL\/TLS\n$ openssl s_client -starttls smtp -connect smtp.domain.com:587\n\r<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Commands<\/h2>\n\n\n\n<p>After connecting, we can use the protocol to send a e-mail<br><br><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>-- First we ourself\nEHLO sender.brbyte.com\n\r\n--- Start authorization\r\nAUTH LOGIN\n\r\n--- Send Username\nZmVybmFuZG9Ac29mdG92LmNvbS5icg==\n\r\n--- Send Password\r\ncGFzc3dvcmQ=\n\r\n--- Start E-mail\r\nMAIL FROM: &lt;fernando@softov.com.br>\n\r\n--- Set Destination\r\nRCPT TO: &lt;softov@brbyte.com>\n\r\n--- Start Data\r\nDATA\n\r\n--- Send Content\r\nMIME-Version: 1.0\r\nFROM: TESTE &lt;fernando@softov.com.br>\r\nTO: SOFTOV &lt;softov@brbyte.com>\r\nSUBJECT: TESTE assunto\r\nContent-Type: text\/plain; charset=UTF-8; format=flowed\r\n\r\nTesting e-mail\r\n\r\n.\r\n\r\n--- Finished<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>One day I was creating a SMTP client and faced some issues or poor documentation about how to simple send a e-mail using a command line tool, to be able to test the server and compare the results with my code to minify the problems. Most of the protocols like SMTP, HTTP are simple TCP&hellip; <a class=\"more-link\" href=\"https:\/\/softov.com.br\/blog\/2022\/08\/13\/smtp-telnet-or-openssl\/\">Continuar lendo <span class=\"screen-reader-text\">SMTP &#8211; Telnet or OpenSSL<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/softov.com.br\/blog\/wp-json\/wp\/v2\/posts\/5093"}],"collection":[{"href":"https:\/\/softov.com.br\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/softov.com.br\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/softov.com.br\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/softov.com.br\/blog\/wp-json\/wp\/v2\/comments?post=5093"}],"version-history":[{"count":1,"href":"https:\/\/softov.com.br\/blog\/wp-json\/wp\/v2\/posts\/5093\/revisions"}],"predecessor-version":[{"id":5094,"href":"https:\/\/softov.com.br\/blog\/wp-json\/wp\/v2\/posts\/5093\/revisions\/5094"}],"wp:attachment":[{"href":"https:\/\/softov.com.br\/blog\/wp-json\/wp\/v2\/media?parent=5093"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/softov.com.br\/blog\/wp-json\/wp\/v2\/categories?post=5093"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/softov.com.br\/blog\/wp-json\/wp\/v2\/tags?post=5093"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}