PC & IT SUPPORT MADE EASY FORUM
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Setup Email & Send Email Via Bash On Linux Example

Go down

Setup Email & Send Email Via Bash On Linux Example Empty Setup Email & Send Email Via Bash On Linux Example

Post by jamied_uk 2nd May 2018, 12:44




Code


Setup.sh

Code:
#!/bin/bash
# (c)J~Net 2018
#
# Usage:
# ./Email.sh
#
#
echo "Welcome To J~Net Email Sender Setup."
value=$(<setup-complete.txt)
#echo "$value"
#
if [ "$value" == "1" ]; then
   echo "Already Setup!"
   # do code here!
  
  
#  end of code
else
   sudo apt-get install -y sendemail libio-socket-ssl-perl libnet-ssleay-perl && echo "1" > setup-complete.txt
  
fi

# Setups First:
#
#

#
#
echo "Setup Complete!.... "
#
#

Email.sh
Code:
#!/bin/bash
# (c)J~Net 2018
#
# Usage:
# ./Email.sh
#
#
echo "Welcome To J~Net Email Sender."
# Setups First:
#
#
# End Of Setups:
#
SMTPFROM="" #  Change This
SMTPTO="" # Change This
SMTPSERVER="smtp.googlemail.com:587" # Gmail For Example Is:
SMTPUSER="" # your gmail login
SMTPPASS="" # your gmail pass
MESSAGEBODY="Testing 123..." # Change this if you need to!
SUBJECT="This Is A Test." # Change this if you need to!
#
# Check If Setup For Sending
value=$(<setup-complete.txt)
#echo "$value"
#
if [ "$value" == "1" ]; then
   echo "Sending Emails..."
   # do code here!
   sendEmail -f $SMTPFROM -t $SMTPTO -u $SUBJECT -m $MESSAGEBODY -s $SMTPSERVER -xu $SMTPUSER -xp $SMTPPASS
  
#  end of code
else
  echo "Installing Required Files"
  ./Setup.sh
fi

# Send:
#
#
echo "Sending Email Complete.... "
#
#


Last edited by jamied_uk on 2nd May 2018, 12:52; edited 1 time in total
jamied_uk
jamied_uk
Admin

Posts : 3053
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

Setup Email & Send Email Via Bash On Linux Example Empty Re: Setup Email & Send Email Via Bash On Linux Example

Post by jamied_uk 2nd May 2018, 12:50

Notes:




jnet.forumotion.com/t1611-setup-email-send-email-via-bash-on-linux-example#2470


Code:
sudo chmod +x *.sh



Code:
./Setup.sh



Looks for if there is a 1 inside text file setup-complete.txt

so to reinstall you can delete the txt file named above and enter password when setting up.



To Send Email Test Page


Fill in your smtp details to login to Gmail inside Email.sh.


Then run

Code:
./Email.sh
jamied_uk
jamied_uk
Admin

Posts : 3053
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

Setup Email & Send Email Via Bash On Linux Example Empty Re: Setup Email & Send Email Via Bash On Linux Example

Post by jamied_uk 2nd May 2018, 12:54

Box Link For Files

https://app.box.com/s/hjfmyhee94vkwol9qvos68breiyupkyy

app.box.com/s/hjfmyhee94vkwol9qvos68breiyupkyy
jamied_uk
jamied_uk
Admin

Posts : 3053
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

Setup Email & Send Email Via Bash On Linux Example Empty Re: Setup Email & Send Email Via Bash On Linux Example

Post by jamied_uk 2nd May 2018, 14:41

Update:

Send Email Using text from a File




Code:


Email-file.sh


Code:
#!/bin/bash
# (c)J~Net 2018
#
#
# jnet.forumotion.com/t1611-setup-email-send-email-via-bash-on-linux-example#2470
#
# Usage:
# ./Email-file.sh
#
#
RED='\033[0;31m'
NC='\033[0m' # No Color
#
text="Welcome To J~Net Email Sender."
#
printf "${RED}$text${NC} \n"
# Setups First:
#
SMTPFROM="" #  Change This
SMTPTO="" # Change This
SMTPSERVER="smtp.googlemail.com:587" # Gmail For Example Is:
SMTPUSER="" # your gmail login
SMTPPASS="" # your gmail pass
MESSAGEBODY="Testing 123..." # Change this if you need to!
SUBJECT="This Is A Test." # Change this if you need to!
#
textfile="textfile.txt"
#
#  End Of Setups:
#
# -m $MESSAGEBODY
# -o file.txt
#
# Check If Setup For Sending
value=$(<setup-complete.txt)
#
if [ "$value" == "1" ]; then
   echo "Sending Emails..."
   # do code here!
   sendEmail -f $SMTPFROM -t $SMTPTO -u $SUBJECT -o message-file=$textfile -s $SMTPSERVER -xu $SMTPUSER -xp $SMTPPASS
#
#  end of code
else
  echo "Installing Required Files"
  ./Setup.sh
fi

# Send:
#
#
echo "Sending Email Complete.... "
#
#
Code:
./Email-file.sh



textfile.txt

Code:
Test


Last edited by jamied_uk on 2nd May 2018, 15:18; edited 4 times in total
jamied_uk
jamied_uk
Admin

Posts : 3053
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

Setup Email & Send Email Via Bash On Linux Example Empty Re: Setup Email & Send Email Via Bash On Linux Example

Post by jamied_uk 2nd May 2018, 15:01

Please Note: You may have to enable from gmail account less secure logins in there options to allow this to work in some places or times! based on country settings or account settings.
jamied_uk
jamied_uk
Admin

Posts : 3053
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

Setup Email & Send Email Via Bash On Linux Example Empty Re: Setup Email & Send Email Via Bash On Linux Example

Post by jamied_uk 2nd May 2018, 15:35

Vid


.Ask.sh


Code:
./Ask.sh




Code:
#!/bin/bash
# (c)J~Net 2018
#
#
# jnet.forumotion.com/t1611-setup-email-send-email-via-bash-on-linux-example#2470
#
# Usage:
# ./Email-file.sh
#
#
RED='\033[0;31m'
NC='\033[0m' # No Color
#
text="Welcome To J~Net Email Sender."
#
printf "${RED}$text${NC} \n"
# Setups First:
#
#
# End Of Setups:
#
SMTPFROM="" #  Change This
SMTPTO="" # Change This
SMTPSERVER="smtp.googlemail.com:587" # Gmail For Example Is:
SMTPUSER="" # your gmail login
SMTPPASS="" # your gmail pass
MESSAGEBODY="Testing 123..." # Change this if you need to!
SUBJECT="This Is A Test." # Change this if you need to!
#
textfile="textfile.txt"
#
#  End Of Setups:
#
# Ask if happy with textfile.txt
#
#
printf "Happy With ${RED}$textfile${NC} ? Y / N\n"
#
read replyone
#
#
if [ "$replyone" == "Y" ]; then
#
# -m $MESSAGEBODY
# -o file.txt
#
# Check If Setup For Sending
value=$(<setup-complete.txt)
#
if [ "$value" == "1" ]; then
   echo "Sending Emails..."
   # do code here!
   sendEmail -f $SMTPFROM -t $SMTPTO -u $SUBJECT -o message-file=$textfile -s $SMTPSERVER -xu $SMTPUSER -xp $SMTPPASS
#
#  end of code
else
  echo "Installing Required Files"
  ./Setup.sh
fi

# Send:
#
#
echo "Sending Email Complete.... "
#
#
else
  echo "Exiting..."
 
fi
jamied_uk
jamied_uk
Admin

Posts : 3053
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

Setup Email & Send Email Via Bash On Linux Example Empty Re: Setup Email & Send Email Via Bash On Linux Example

Post by jamied_uk 2nd May 2018, 17:19

Vid


Code:
./edit.sh




Code:
 #!/bin/bash
# (c) J~Net 2018
#
#
# jnet.forumotion.com/t1611-setup-email-send-email-via-bash-on-linux-example#2470
#
# Usage:
# ./edit.sh
#
#
RED='\033[0;31m'
NC='\033[0m' # No Color
#
text="Welcome To J~Net Email Edit Menu."
echo ""
#
printf "${RED}$text${NC} \n"
#
read -r -p 'Enter Email Text:  ' textcontent
echo $textcontent > content.txt
echo ""
cat content.txt
echo ""
text="Updated! To File content.txt."
printf "${RED}$text${NC} \n"
echo ""
jamied_uk
jamied_uk
Admin

Posts : 3053
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

Setup Email & Send Email Via Bash On Linux Example Empty Re: Setup Email & Send Email Via Bash On Linux Example

Post by jamied_uk 2nd May 2018, 18:31

Menu.sh

Code:
./Menu.sh




Code:
#!/bin/bash
# (c)J~Net 2018
#
#
# jnet.forumotion.com/t1611-setup-email-send-email-via-bash-on-linux-example#2470
#
# Usage:
# ./edit.sh
#
#
RED='\033[0;31m'
NC='\033[0m' # No Color
#
text="Welcome To J~Net Email Edit Menu."
#
printf "${RED}$text${NC} \n"
#
#
select fname in *.sh;
do
    echo you picked $fname \($REPLY\)
    bash $fname \($REPLY\)
break;
done
jamied_uk
jamied_uk
Admin

Posts : 3053
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

Setup Email & Send Email Via Bash On Linux Example Empty Re: Setup Email & Send Email Via Bash On Linux Example

Post by jamied_uk 2nd May 2018, 19:51

Sending Email Bash Menu  & File Attachment Example On Linux




Code:

Use Update Link For All Files & Updates
jamied_uk
jamied_uk
Admin

Posts : 3053
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

Setup Email & Send Email Via Bash On Linux Example Empty Re: Setup Email & Send Email Via Bash On Linux Example

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum