Skip to main content

Sending SMTP Email via Telnet

You want your webhost to be able to send emails through an external SMTP server. The first thing to do is to check whether your webhost provider allows this to happen. Some concerned providers block outgoing SMTP ports to prevent you from doing email spamming. Let's try to connect with the SMTP server via Telnet from within your webhost. You may need to SSH into your webhost first. And then issue the following command:

$ telnet -4 mail.example.com 587

The above command will connect to the mail.example.com SMTP server via port 587 and force Telnet to use IPv4. If the connection fails then your webhost provider may have blocked the outgoing SMTP port 587. You may need to politely ask your webhost provider to open the port for you. You can't do it yourself.

Note: Telnet will resolve to IPv6 by default. If the SMTP port is not open on IPv6 then Telnet will appear hung until all trials via IPv6 connections are timed out. If IPv6 failed then it will resolve to IPv4. 

Telnet should have received a response like the following:

Trying xxx.xxx.xxx.xxx...
Connected to smtp.server.com.
Escape character is '^]'.
220 smtp.server.com ESMTP Exim 4.95 Thu, 30 Jun 2022 20:33:24 +0000

Say hello to the SMTP server. You must do this before sending an email:
ehlo mail.example.com

It will respond like the following:
250-smtp.server.com Hello mail.example.com [xxx.xxx.xxx.xxx]
250-SIZE 52428800
250-8BITMIME
250-PIPELINING
250-PIPE_CONNECT
250-AUTH PLAIN LOGIN
250-STARTTLS
250 HELP

Then you need to login using an email credential with the SMTP server:
auth login

It will ask for an email username:
334 VXNlcm5hbWU6

VXNlcm5hbWU6 is a base64 encoded string which will decode to Username:

Enter the based64 encoded username (i.e username as in username@example.com without the @example.com).

Then it will ask for the email password:
334 UGFzc3dvcmQ6

UGFzc3dvcmQ6 is a base64 encoded string which will decode to Password:

Enter the based64 encoded password.

It will respond with:
235 Authentication succeeded

Start composing an email by issueing the data command. No need to encode the content in based64. Then send out the email by ending the composition with a single dot (.) command on the last line:
data
354 Enter message, ending with "." on a line by itself
from: Admin <admin@example.com>
to: someone@gmail.com
Subject: Greetings from Webhost via Telnet

Hi!
This is a RFC 5322 compliant email sent using telnet from a webhost.
.
250 OK id=1o71wm-0006hR-UR

The '250 OK' response means that your email was accepted, but not necessarily delivered to the destination. 

A RFC 5322 compliant email must have the from: email address. Gmail will not accept an email without the from: email address.

Now you can end the Telnet session:
quit

Verify that the email reaches its destination. But that is beyond Telnet. If the email is stuck somewhere then you need to consult with the SMTP service provider. This test is only to prove that your webhost has a clear communication channel with the SMTP server. Next, you may want to setup mail service in your webhost so that webapps can send emails. 



Comments

Popular posts from this blog

Setting Up PyScripter for Quantum GIS

PyScripter is a general purpose Python Integrated Development Environment (IDE). Quantum GIS (QGIS) is a desktop GIS application that can be extended with Python plugins. Both are open source softwares. We intend to use PyScripter as an IDE to build QGIS Python plugin. We are using PyScripter 2.4.1.0 and QGIS 1.6.0 in Windows. PyScripter does not come with Python. On the other hand, QGIS is built in with Python. Thus, we will setup up PyScripter to use the build in Python in QGIS. We assume both PyScripter and QGIS are already installed. Preparing PyScripter batch file We assume that QGIS is installed in C:\OSGeo4W\ folder and PyScripter is installed in C:\Program Files\PyScripter\ . 1. Copy qgis.bat in C:\OSGeo4W\ bin to pyscripter.bat 2. Edit pyscripter.bat to remove the last line that read something like this start "Quantum GIS" /B "%OSGEO4W_ROOT%"\apps\qgis\bin\qgis.exe %* and replace it with this in one line Start "PyScripter" /B "C:\Progr

Using React in Foundation for Sites

This post was the precursor to the Foundation-React Template . React and Foundation are two different web UI frameworks addressing different needs. They evolve differently. Both of them are powerful on their own accord. Fusing them together may create superpower. We will walk through the process of adding React into Foundation. We will start by installing both Foundation and React through command line interface (CLI). Then we will create a simple Todo web app. Along the way we will highlight the development process. But before all that, let us summarize React and Foundation. The details can be found at their respective websites. Both of them are well documented. React is a run-time UI rendering engine. It renders dynamic UI elements in its own fast virtual DOM, and only update necessary changes to the slow browser DOM. This behaves like a  double buffering DOM which makes any UI update feels fast. React wraps a UI rendering script in a component. A React component can be bound

MicroSD Card Module with SPI Connection

A MicroSD card can be directly connected to a 3.3v microcontroller without the need of any additional module. However, a cheap module such as shown in the picture above can be handy in terms of wiring and card replacement. Yet, if you get the module from China then you are on your own, you have to figure it out yourself how the module works. The module above needs 5v VCC to operate. The 5v is needed by the 3.3v LM1117 regulator to power the MicroSD card and the 74125 bus buffer (the 14-pin IC in the module above). Hence, the bus buffer is operating at 3.3v. The VCC is connected directly to the input of the regulator and no where else. Thus, the VCC is solely meant for the regulator. The right-side SPI bus (CS, SCK, MOSI & MISO) is connected directly to the 3.3v bus buffer. No line in the SPI bus that is connected to the VCC. Thus, the SPI bus does not follow VCC. The buffer is 5v tolerant so the right-side SPI connection can be driven at either 3.3v or 5v. Hence, the SPI ca