From 8ed43c00f09ca5bb4a5e4ac69b801c4b8ed8c0dd Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Mon, 5 Nov 2007 18:24:19 +0000 Subject: [PATCH] add perl fake sendmail git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6162 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- scripts/sendmail | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 scripts/sendmail diff --git a/scripts/sendmail b/scripts/sendmail new file mode 100644 index 0000000000..3011ab3efd --- /dev/null +++ b/scripts/sendmail @@ -0,0 +1,40 @@ +#!/usr/local/bin/perl +################################################################################ +# sendmail.pl +# +# +# (c) 2005 Anthony Minessale II +# Anthony Minessale +# +################################################################################ +use Net::SMTP; +my $relayhost = "localhost"; # what is the internet address of your smtp server +my $over_from = ""; # define this to override the to +my $over_to = ""; # define this to override the from +my $debug = 0; # set to 1 to watch it deliver +my $timeout = 60; # when to give up. +################################################################################ + + +$/ = undef; +my $msg = ; + +my ($to) = $over_to || $msg =~ /To: (.*)/; +my ($from) = $over_from || $msg =~ /From: (.*)/; + + +if($to =~ /<([^>]+)>/) { + $to = $1; +} + +if($from =~ /<([^>]+)>/) { + $from = $1; +} + +my $smtp = Net::SMTP->new($relayhost, Debug => $debug, Timeout => $timout); +$smtp->mail($from); +$smtp->to(split /,/, $to); +$smtp->data($msg); +$smtp->quit(); +