Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. function checkStatus {
  4. expect=250
  5. if [ $# -eq 3 ] ; then
  6. expect="${3}"
  7. fi
  8. if [ $1 -ne $expect ] ; then
  9. echo "Error: ${2}"
  10. exit
  11. fi
  12. }
  13.  
  14. MyHost=`hostname`
  15.  
  16. read -p "Enter your mail host: " MailHost
  17. MailPort=25
  18.  
  19. read -p "From: " FromAddr
  20.  
  21. read -p "To: " ToAddr
  22.  
  23. read -p "Subject: " Subject
  24.  
  25. read -p "Message: " Message
  26.  
  27. exec 3<>/dev/tcp/${MailHost}/${MailPort}
  28.  
  29. read -u 3 sts line
  30. checkStatus "${sts}" "${line}" 220
  31.  
  32. echo "HELO ${MyHost}" >&3
  33.  
  34. read -u 3 sts line
  35. checkStatus "$sts" "$line"
  36.  
  37. echo "MAIL FROM: ${FromAddr}" >&3
  38.  
  39. read -u 3 sts line
  40. checkStatus "$sts" "$line"
  41.  
  42. echo "RCPT TO: ${ToAddr}" >&3
  43.  
  44. read -u 3 sts line
  45. checkStatus "$sts" "$line"
  46.  
  47. echo "DATA" >&3
  48.  
  49. read -u 3 sts line
  50. checkStatus "$sts" "$line" 354
  51.  
  52. echo "Subject: ${Subject}" >&3
  53. echo "${Message}" >&3
  54. echo "." >&3
  55.  
  56. read -u 3 sts line
  57. checkStatus "$sts" "$line"
  58.  
  59. #!/bin/bash
  60. # Use "host -t mx yourispdomain" to find out yourispmailserver
  61. exec 1<>/dev/tcp/yourispmailserver/25
  62. a=$(cat <<"MAILEND"
  63. HELO local.domain.name
  64. MAIL FROM: <me@local.domain.name>
  65. RCPT TO: <you@local.domain.name>
  66. DATA
  67. From: me@local.domain.name
  68. To: you@local.domain.name
  69. Subject: test
  70. send your orders for pizza to the administrator.
  71. .
  72. QUIT
  73. .
  74. MAILEND
  75. )
  76. IFS='
  77. '
  78. declare -a b=($a)
  79. for x in "${b[@]}"
  80. do
  81. echo $x
  82. sleep 1
  83. done
  84.  
  85. #/bin/bash
  86.  
  87. FROM='from@test.com'
  88. TO='to@test.com'
  89. SUBJECT='This is a test message'
  90.  
  91. BODY="This is a test mail message body.
  92. Hi there.
  93. "
  94.  
  95. printf "From: <%s>nTo: <%s>nSubject: %snn%s" "$FROM" "$TO" "$SUBJECT" "$BODY" | sendmail -f "$FROM"
  96.  
  97. SERVER="smtp.company.com"
  98. FROM="sender@company.com"
  99. TO="recepient@company.com"
  100. SUBJ="Some subject"
  101. MESSAGE="Some message"
  102. CHARSET="utf-8"
  103.  
  104. 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