Ubuntu/Scripts
From r00tedvw.com wiki
(Difference between revisions)
(Created page with "==Email current IP address== #!/bin/bash -x #define varibles #HOSTNAME=`hostname` from="$HOSTNAME"'@sender domain.com' to='recipient address' recipient_mx='recipient m...") |
|||
Line 1: | Line 1: | ||
==Email current IP address== | ==Email current IP address== | ||
+ | ====Variables needing to be defined:==== | ||
+ | *sender domain (@sennder domain.com) | ||
+ | *recipient (recipient address) | ||
+ | *recipient mail exchanger (recipient mail exchanger) | ||
+ | |||
+ | ====Variables automatically defined==== | ||
+ | *HOSTNAME - defined by using the hostname command | ||
+ | *DATE - defined by using the date command | ||
+ | |||
+ | ====Code==== | ||
#!/bin/bash -x | #!/bin/bash -x | ||
− | #define | + | #define variables |
#HOSTNAME=`hostname` | #HOSTNAME=`hostname` | ||
from="$HOSTNAME"'@sender domain.com' | from="$HOSTNAME"'@sender domain.com' |
Revision as of 00:15, 22 June 2014
Contents |
Email current IP address
Variables needing to be defined:
- sender domain (@sennder domain.com)
- recipient (recipient address)
- recipient mail exchanger (recipient mail exchanger)
Variables automatically defined
- HOSTNAME - defined by using the hostname command
- DATE - defined by using the date command
Code
#!/bin/bash -x #define variables #HOSTNAME=`hostname` from="$HOSTNAME"'@sender domain.com' to='recipient address' recipient_mx='recipient mail exchanger' DATE=`date` messageid='[email protected]' IP=$(curl checkip.dyndns.org|awk '/Address:/ {print$6}'|sed 's/<.*/ /') #function containing mail commands. Contains enough RFC required fields to satisfy gmail's requirements to allow the message, though it may be detected as spam if you do not have a SPF record. function mail_input { sleep 1 echo 'ehlo test.com\n' sleep 0.5 printf 'mail from:<'"$from"'>\n' sleep 1 printf 'rcpt to:<'"$to"'>\n' sleep 1 printf 'data\n' sleep 0.5 printf 'Return-Path: <'"$from"'>\n' printf 'Date: '"$DATE"'\n' printf 'Message-ID: <'"$messageid"'>\n' printf 'Subject: test\n' printf 'From: <'"$from"'>\n' printf 'To: <'"$to"'>\n' printf "$HOSTNAME"' ip address= '"$IP"'\n' printf '.\n' printf 'quit' } #sending mail with mail_input function mail_input | telnet $recipient_mx 25 || exit exit