I have an email-to-cgi script below that processes an incoming email with an mp3 file attachment (a voicemail message) and forwards it out as though it came from me and not the voice email service I'm using.
The email-to-cgi script works great except that it can't forward "based on any input in the subject line of the incoming email"
There are voice email services that allow callers to enter a series of numbers at the end of their voicemail message that gets inserted into the subject line of the voice email.
What I'd like is to have my script revised so that when a voice email message is received, it will forward the message to an email address based on what's in the subject line of the incoming email with the voicemail attachment and also place a portion of what's in the subject line of the incoming email (like the series of numbers being entered after leaving a message as described above) included in the subject line of the outgoing email after it leaves my email-to-cgi script.
Is this possible?
Here's the email-to-cgi script I'm using now
--------------------------
----------
----------
----------
----------
----------
----
#!/usr/bin/perl -w
use strict;
use MIME::Parser;
use MIME::Lite;
my $attachdir='/usr/home/doma
inname.com
/cgi-bin/e
xtract_&_s
end/';
my $parser=new MIME::Parser;
$parser->ignore_errors(1);
$parser->extract_uuencode(
1);
$parser->tmp_recycling(0);
$parser->output_to_core(1)
;
my $entity=$parser->parse(\*S
TDIN);
my $from=$entity->head->get('
From');
my $subject=$entity->head->ge
t('Subject
');
my @parts=$entity->parts;
my $aname='attachment001';
while(my $part = shift(@parts)) {
if($part->parts) {
push @parts,$part->parts; # Nested multi-part
next;
}
my $type=$part->head->mime_ty
pe || $part->head->effective_typ
e;
if($type !~ /^(text|message)/i) { # Not a text, save it
my $filename=$part->head->rec
ommended_f
ilename || $aname;
$aname++;
my $io=$part->open("r");
$filename = "voicemail.mp3";
open(F,"> $attachdir/$filename");
my $buf;
while($io->read($buf,1024)
) {
print F $buf;
}
close(F);
$io->close;
my @email=<STDIN>;
my $msg = MIME::Lite->new(
To => 'to-email@att.net',
From => 'from-email@att.net',
Bcc => 'bcc-email@att.net',
Subject => 'Inquiry on Listing #1',
Type => 'multipart/mixed',
);
$msg->attach(Type =>'TEXT',
Data =>"To Whom it May Concern:
Content of my email message goes here
Kindest Regards,
Administrator"
);
$msg->attach(
Type => 'audio/x-mpeg',
Path => "$attachdir/$filename",
);
$msg->send;
}
}
exit;
Start Free Trial