Send email secure (or not)

Send email secure (or not)

Email is send with the Simple Mail Transfer Protocol ( SMTP ). It was invented back in the day (1982) when the Internet was run by people with the best intentions and de security was not needed or perceived not necessary. When you are sending an email the text, headers, email addresses, etc. are send over the Internet in plain-text (human readable). See for an example.

Anyone that has access to the data stream (free WiFi is not your friend) can in theory read your emails. Not a save way of using email. What we need is a solution that will hide your emails from prying eyes. Cryptography to the rescue!

Most modern email providers like Gmail support Transport Layers (TLS). TLS encrypts all the network traffic making it unintelligible. TLS email is called STARTLS and is negotiated between de mail client and mail server. Normally a user cannot choose to use STARTTLS. It the mail server (administrator) to decide how to handle the SMTP traffic. Because of the move of the Internet to encrypt everything it will be a matter of time of STARTTLS will be the normal way of sending email.

To check if an email server supports TLS (STARTTLS) you can use the TLS check script tlschk (script below) Linux script.

# tslchk -d
TLS check for SMTP server for domain, hang on this could take a while.... version is TLSv1.2 version is not available or TLS not supported version is not available or TLS not supported
domain ready.

When an TLSVx.x answer is returned STARTTLS (TLS) is supported.

# nslookup & openssl must be installed!
OPTIND=1 # Reset in case getopts has been used previously in the shell.

function showHelp {
	echo $PRGNAME" -d <mail domain>"
	echo "Example: "$PRGNAME" -d "

while getopts "h?d:" opt; do
    case "$opt" in
        exit 0

shift $((OPTIND-1))

[ "$1" = "--" ] && shift

if [ -z "${DOMAINNAME}" ]; then

# tell what domain that will be checked
echo "TLS check for SMTP server for domain "$DOMAINNAME", hang on this could take a while...."
# find MX record, used first one that we find.
MXLIST=$(nslookup -query=mx $DOMAINNAME | grep $DOMAINNAME |cut -d ' ' -f5)

for mxrec in $MXLIST
	#echo "checking MX record "$mxrec
	OUTPUT=$(echo "Q"|openssl s_client  -starttls smtp  -crlf -connect $mxrec:25 2>/dev/null | tr -d ' '| grep Protocol: | cut -d ':' -f2)
	if [ -z "${OUTPUT}" ]; then
		echo $mxrec" version is not available or TLS not supported"
		echo $mxrec" version is "$OUTPUT
echo "domain "$DOMAINNAME" ready."


One Reply to “Send email secure (or not)”

Geef een reactie.

Deze site gebruikt Akismet om spam te verminderen. Bekijk hoe je reactie-gegevens worden verwerkt.