Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- function checkStatus {
- expect=250
- if [ $# -eq 3 ] ; then
- expect="${3}"
- fi
- if [ $1 -ne $expect ] ; then
- echo "Error: ${2}"
- exit
- fi
- }
- MyHost=`hostname`
- read -p "Enter your mail host: " MailHost
- MailPort=25
- read -p "From: " FromAddr
- read -p "To: " ToAddr
- read -p "Subject: " Subject
- read -p "Message: " Message
- exec 3<>/dev/tcp/${MailHost}/${MailPort}
- read -u 3 sts line
- checkStatus "${sts}" "${line}" 220
- echo "HELO ${MyHost}" >&3
- read -u 3 sts line
- checkStatus "$sts" "$line"
- echo "MAIL FROM: ${FromAddr}" >&3
- read -u 3 sts line
- checkStatus "$sts" "$line"
- echo "RCPT TO: ${ToAddr}" >&3
- read -u 3 sts line
- checkStatus "$sts" "$line"
- echo "DATA" >&3
- read -u 3 sts line
- checkStatus "$sts" "$line" 354
- echo "Subject: ${Subject}" >&3
- echo "${Message}" >&3
- echo "." >&3
- read -u 3 sts line
- checkStatus "$sts" "$line"
- #!/bin/bash
- # Use "host -t mx yourispdomain" to find out yourispmailserver
- exec 1<>/dev/tcp/yourispmailserver/25
- a=$(cat <<"MAILEND"
- HELO local.domain.name
- MAIL FROM: <me@local.domain.name>
- RCPT TO: <you@local.domain.name>
- DATA
- From: me@local.domain.name
- To: you@local.domain.name
- Subject: test
- send your orders for pizza to the administrator.
- .
- QUIT
- .
- MAILEND
- )
- IFS='
- '
- declare -a b=($a)
- for x in "${b[@]}"
- do
- echo $x
- sleep 1
- done
- #/bin/bash
- FROM='from@test.com'
- TO='to@test.com'
- SUBJECT='This is a test message'
- BODY="This is a test mail message body.
- Hi there.
- "
- printf "From: <%s>nTo: <%s>nSubject: %snn%s" "$FROM" "$TO" "$SUBJECT" "$BODY" | sendmail -f "$FROM"
- SERVER="smtp.company.com"
- FROM="sender@company.com"
- TO="recepient@company.com"
- SUBJ="Some subject"
- MESSAGE="Some message"
- CHARSET="utf-8"
- sendemail -f $FROM -t $TO -u $SUBJ -s $SERVER -m $MESSAGE -v -o message-charset=$CHARSET
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement