Skip to content

Instantly share code, notes, and snippets.

@ziozzang
Last active January 29, 2019 06:38
Show Gist options
  • Save ziozzang/5f646910bc11d90afc3a1afa6d240b41 to your computer and use it in GitHub Desktop.
Save ziozzang/5f646910bc11d90afc3a1afa6d240b41 to your computer and use it in GitHub Desktop.
Simple SMTP test with shell script(bash)
#!/bin/bash
EMAIL_BODY="Test from telnet - $(LANG=c date)"
EMAIL_SUBJECT="Telnet test - $(LANG=c date)"
SMTP_SERVER="smtp.some.server"
SMTP_PORT="25"
MAIL_TO="asdf@foo.com"
MAIL_FROM="asdf@bar.com"
echo ">> ${my_email_subject}"
nc ${SMTP_SERVER} ${SMTP_PORT} << EOF
EHLO simple.bash.client
MAIL FROM:${MAIL_FROM}
RCPT TO:${MAIL_TO}
DATA
FROM:${MAIL_FROM}
TO:${MAIL_TO}
SUBJECT: ${EMAIL_SUBJECT}
${EMAIL_BODY}
.
QUIT
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment