Cool Solutions

Script for testing SMTP with Telnet

Laura Buckley

By:

January 2, 2018 9:17 am

Reads:527

Comments:0

Score:5

Print/PDF

There are times when we, as email system administrators, may have issues with mail flow between our GWIAs and external systems. A common troubleshooting step is to go back to basics and use Telnet to test the SMTP connectivity and send a test email. This troubleshooting step can prove invaluable and assist us in diagnosing where the problem is. To make my life a little easier I wrote a script which [almost] automates this task for me, negating the need to remember the exact commands and syntax. I have found this useful and thought I’d share here.

Disclaimer:  This was created out of my own necessity.  Scripting does not come naturally to me, so this won’t look pretty.

On your GWIA server, in an appropriate directory, create a file. I call it telnet.sh

Copy this code into the file:

#!/bin/bash

read -p "Enter Recipient's Mail Server: " server
read -p "Enter SMTP Port: " port
read -p "Enter Your Email Address: " from
read -p "Enter Recipient's Email Address: " to

# create message
function mail_input {
echo "ehlo $(hostname -f)"
echo "MAIL FROM: <$from>"
echo "RCPT TO: <$to>"
echo "DATA"
echo "From: <$from>"
echo "To: <$to>"
echo "Subject: Testing SMTP Mail"
echo "This is only a test. Please do not panic. If this works, then all is well, else all is not well."
echo "."
echo "quit"
}

mail_input | netcat $server $port || err_exit 

 
Save the file and mark it executable

 chmod +x telnet.sh 

Edit the subject line and text to be sent in the email to suit your needs. When you run the script it will prompt you for the necessary information to complete the task at hand.

Enjoy!

1 vote, average: 5.00 out of 51 vote, average: 5.00 out of 51 vote, average: 5.00 out of 51 vote, average: 5.00 out of 51 vote, average: 5.00 out of 5 (1 votes, average: 5.00 out of 5)
You need to be a registered member to rate this post.
Loading...

Tags: , ,
Categories: Collaboration, GroupWise, Messaging & Team Collaboration, Technical

0

Disclaimer: This content is not supported by Micro Focus. It was contributed by a community member and is published "as is." It seems to have worked for at least one person, and might work for you. But please be sure to test it thoroughly before using it in a production environment.

Comment

RSS