Public Domain
#!/bin/bash
TMP=$(mktemp)
FROM_EMAIL_ADDRESS="me@test.com"
TO_EMAIL_ADDRESS="you@example.net"
EMAIL_SUBJECT="This is email subject"
SMTP="192.168.1.10"
FRIENDLY_NAME="$(hostname)"
EMAIL_ACCOUNT_PASSWORD="123456"
cat > $TMP << EOF
This is email body
This is email body
This is email body
EOF
cat $TMP | \
mailx -v -s "${EMAIL_SUBJECT}" \
-S smtp-auth=cram-md5 \
-S smtp=${SMTP} \
-S from="${FROM_EMAIL_ADDRESS}(${FRIENDLY_NAME})" \
-S smtp-auth-user=$FROM_EMAIL_ADDRESS \
-S smtp-auth-password=$EMAIL_ACCOUNT_PASSWORD \
-S nss-config-dir=~/.mozilla/firefox/xxxxxxxx.default/ \
$TO_EMAIL_ADDRESS
[ -e $TMP ] && rm $TMP
#!/bin/bash
TMP=$(mktemp)
FROM_EMAIL_ADDRESS="me@test.com"
TO_EMAIL_ADDRESS="you@example.net"
EMAIL_SUBJECT="This is email subject"
SMTP="192.168.1.10"
FRIENDLY_NAME="$(hostname)"
cat > $TMP << EOF
This is email body
This is email body
This is email body
EOF
cat $TMP | \
mailx -v -s "${EMAIL_SUBJECT}" \
-S smtp=${SMTP} \
-S from="${FROM_EMAIL_ADDRESS}(${FRIENDLY_NAME})" \
$TO_EMAIL_ADDRESS
[ -e $TMP ] && rm $TMP
BY: Pejman Moghadam
TAG: mailx, smtp, email, bash
DATE: 2014-01-26 16:53:47