#!/bin/bash DATE="`date +%Y%m%d-%H%M%S`" FROM_SERVER="localhost" MAIL_FROM_NAME="user-name-of-email-address" MAIL_FROM_DOMAIN="domain-of-email-address" MAIL_FROM="<$MAIL_FROM_NAME@$MAIL_FROM_DOMAIN>" MAIL_TO="email-address-of-recipient" MAIL_TO="<$MAIL_TO>" MAIL_TO_NAME="`echo $MAIL_TO | cut -d '@' -f 1 | sed -e's/<//'`" MAIL_TO_DOMAIN="`echo $MAIL_TO | cut -d '@' -f 2 | sed -e's/>//'`" MAIL_SERVER="ip-or-hostname-of-recipient-mail-server" ## if you want to get automaticaly the recipient mail-server uncoment this two lines #MAIL_SERVER="`dig -t MX $MAIL_TO_DOMAIN | grep -A 1 "ANSWER SECTION:" | tail -n 1`" #MAIL_SERVER="`echo $MAIL_SERVER | cut -d ' ' -f 6 | sed -e's/\.$//'`" MAIL_PORT="25" SLEEPTIME=3 SUBJECT="subject-of-email" BODY="text-body-of-email" echo "## zusammenfassung ##"; echo "telnet $MAIL_SERVER"; echo "ehlo $FROM_SERVER"; echo "mail from: $MAIL_FROM"; echo "rcpt to: $MAIL_TO"; echo "data"; echo "from: $MAIL_FROM"; echo "to: $MAIL_TO"; echo "subject: $SUBJECT"; echo " "; echo "$BODY"; echo "."; echo "quit"; echo "## now real run ##"; ( sleep $SLEEPTIME echo "ehlo $FROM_SERVER" echo "ehlo $FROM_SERVER" 1>&2 sleep $SLEEPTIME echo "mail from: $MAIL_FROM" echo "mail from: $MAIL_FROM" 1>&2 sleep $SLEEPTIME echo "rcpt to: $MAIL_TO" echo "rcpt to: $MAIL_TO" 1>&2 sleep $SLEEPTIME echo "data" echo "data" 1>&2 sleep $SLEEPTIME echo "from: $MAIL_FROM" echo "from: $MAIL_FROM" 1>&2 sleep $SLEEPTIME echo "to: $MAIL_TO" echo "to: $MAIL_TO" 1>&2 sleep $SLEEPTIME echo "subject: $SUBJECT" echo "subject: $SUBJECT" 1>&2 sleep $SLEEPTIME echo "" echo " " 1>&2 sleep $SLEEPTIME echo "$BODY" echo "$BODY" 1>&2 sleep $SLEEPTIME echo "." echo "." 1>&2 sleep $SLEEPTIME echo "quit" echo "quit" 1>&2 ) | telnet $MAIL_SERVER $MAIL_PORT