#!/usr/bin/perl -w
#---------------------------------------------------------------------
# gsgimp-sms2email
#---------------------------------------------------------------------
# (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_client,$arg_command) = @ARGV;

my $program_name = "gsgimp-sms2email";
my $program_version = "v0.0.1 - November 4, 2000";
my $gateway_domain = "domain.com";
my $tmpfile = "/tmp/".$program_name.".".$$;

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

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

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

