#!/usr/bin/perl -w
#---------------------------------------------------------------------
# gsgimp-sms21email
#---------------------------------------------------------------------
# (C) Andrs Seco Hernndez, November 2000
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
#---------------------------------------------------------------------

use strict;

my ($arg_from,$arg_content) = @ARGV;

my $program_name = "gsgimp-sms21email";
my $program_version = "v0.0.1 - January 29, 2000";
my $gateway_email = "email2sms\@wanadoo.es";
my $tmpfile = "/tmp/".$program_name.".".$$;

my @tokens = split(/#/,$arg_content);

print "from: $arg_from\n";
print "to: $tokens[0]\n";
print "content: $tokens[1]\n";

umask 007;
open (MSGFILE,">$tmpfile");
print MSGFILE "From: ".$gateway_email."\n";
print MSGFILE "To: ".$tokens[0]."\n";
print MSGFILE "Subject: ".$arg_from."\n";
print MSGFILE "\n";
print MSGFILE $tokens[1]."\n";
close (MSGFILE);

my $commandtorun = "cat ".$tmpfile." | sendmail -t";
system($commandtorun);
unlink $tmpfile;

