Setup Email & Send Email Via Bash On Linux Example
Page 1 of 1
Setup Email & Send Email Via Bash On Linux Example
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
Re: Setup Email & Send Email Via Bash On Linux Example
Notes:
jnet.forumotion.com/t1611-setup-email-send-email-via-bash-on-linux-example#2470
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
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
Re: Setup Email & Send Email Via Bash On Linux Example
Box Link For Files
https://app.box.com/s/hjfmyhee94vkwol9qvos68breiyupkyy
app.box.com/s/hjfmyhee94vkwol9qvos68breiyupkyy
https://app.box.com/s/hjfmyhee94vkwol9qvos68breiyupkyy
app.box.com/s/hjfmyhee94vkwol9qvos68breiyupkyy
Re: Setup Email & Send Email Via Bash On Linux Example
Update:
Send Email Using text from a File
Code:
Email-file.sh
textfile.txt
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
Re: Setup Email & Send Email Via Bash On Linux Example
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.
Re: Setup Email & Send Email Via Bash On Linux Example
Vid
.Ask.sh
.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
Re: Setup Email & Send Email Via Bash On Linux Example
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 ""
Re: Setup Email & Send Email Via Bash On Linux Example
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
Re: Setup Email & Send Email Via Bash On Linux Example
Sending Email Bash Menu & File Attachment Example On Linux
Code:
Use Update Link For All Files & Updates
Code:
Use Update Link For All Files & Updates
Similar topics
» Linux BASH Script Running Commands and Functions From Bash Script and saving to varables
» How to: Change / Setup bash custom prompt (PS1)
» LINUX RASPBERRY PI PBX SETUP
» Bash Psychic Game For Linux Bash
» Surpress Crontab Email Alarts to stop error emails on linux
» How to: Change / Setup bash custom prompt (PS1)
» LINUX RASPBERRY PI PBX SETUP
» Bash Psychic Game For Linux Bash
» Surpress Crontab Email Alarts to stop error emails on linux
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum