Skip to content

Commit 6b01bf4

Browse files
NerdOfCodezma
authored andcommitted
Initial Upload
This is a script that easily sends emails using Postfix and Mailutils.
1 parent 6c89fe5 commit 6b01bf4

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

script/sendmail.sh

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/bin/bash
2+
3+
#for saving the mail temporarily
4+
random=$RANDOM
5+
6+
#Mail related functionality
7+
mail=$(which mailutils)
8+
mail_status=$?
9+
check_ser=$(which postfix)
10+
check_ser_status=$?
11+
temp_d=/tmp/
12+
mail_ext=.mail
13+
14+
#Checking GUI related functions
15+
gui_check="$(startx >/dev/null 2>&1)"
16+
gui_status=$?
17+
18+
19+
echo -e "THIS PROGRAM IS OF NO WARRANTY!!! I AM NOT RESPONSIBLE FOR ANY
20+
MISUSES OF IT. THIS SCRIPT IS SOLELY FOR EDUCATIONAL PURPOSES \n \n"
21+
sleep 5
22+
clear
23+
24+
25+
if [ $mail_status != 0 ]
26+
then
27+
echo "I am very sorry... But I require the mailutils package to sendmail"
28+
echo "I suggest using apt or yum to install"
29+
exit 1
30+
fi
31+
32+
if [ $check_ser_status != 0 ]
33+
then
34+
echo "I am very sorry... But I require the Postfix service"
35+
echo "I suggest using apt or yum to install"
36+
exit 1
37+
fi
38+
39+
if [ $gui_status == 0 ]
40+
then
41+
echo "WARNING!!! Running on home Computer is highly not recommended due to the increased chance of being mislead as spam"
42+
sleep 2
43+
exit 1
44+
fi
45+
46+
47+
read -p "Enter from address: " from
48+
read -p "Enter receiving address: " receive
49+
read -p "Enter subject: " subject
50+
echo "Enter message in one second: "
51+
sleep 2
52+
#Open a file to edit the body of a message
53+
nano $temp_d$random$mail_ext
54+
body=$(cat $temp_d$random$mail_ext)
55+
56+
read -p "Ready to send? (yes): " send
57+
58+
if [ $send == "yes" ]
59+
then
60+
echo $body | mail -aFrom:$from -s "$subject" $receive
61+
exit 0
62+
else
63+
echo "The body of your message was stored here: $temp_d$random$mail_ext"
64+
exit 0
65+
fi

0 commit comments

Comments
 (0)