#!/bin/bash
# Spam-Em version 0.2.
# Under GPL Public License Ver 2.0
# No Warranties Use at your own risk
# Written by hipodilski.
# I hate SPAM. This is written just for advancing my
# shellscript knowledge, don't use it to spam ppl.
# Best Wishes, hip0.

a=0
b=1

# MailServer to use.
sendmail_server=localhost

# MailServer Port.
sendmail_port="25";

# Info File to send as text.
data_file="test.text";

# Don't Edit here.
string0="$0";
string1="$1";
string2="$2";
mail_name="$2";

# Mails Subjects.
subject="Change your info!";

 chk_args () {
 if [ -z "$string1" ] || [ -z "$string2" ]; then
  printf "SpaM-Em ver. 0.4\n";
   echo   '-=-=-=-=-=-=-=-=';
    printf "Bad Syntax:\n";
   printf "Syntax is:"; 
  echo "$string0 mail_list mail_to_mask_as@domain.xxx";
 exit 0;
 fi
 }

 init_data () {
  miniloop=`wc -l $string1 | awk '{ print $1 }'`
  data=`cat $data_file`;
 }

 banner () {
  clear
   printf "SpaM-Em ver. 0.4\n";
    echo   '-=-=-=-=-=-=-=-';
   echo "Sending mails masked as $mail_name";
  echo 'Relax:]';
 }

 spam_cycle () {
  while [ "$a" -lt "$miniloop" ]; do
   a=$(( $a + $b ));
    name="`cat $string1 | head -n $a | tail -n 1 | head -n 1`";
     recipient_name="$name";
    (echo -e "HELO localhost\n"; 
   echo -e "MAIL FROM:$mail_name\n";
  echo -e "RCPT TO:$recipient_name\n";
 echo -e "DATA"; 
echo -e "Subject:$subject\n";
 echo -e "$data\n.\n";
  echo -e "QUIT\n";sleep 1) |\
  telnet $sendmail_server $sendmail_port &> /dev/null
 done
 }

 main () {
  chk_args;
   banner;
    init_data;
   spam_cycle;
 }
  main;


