aboutsummaryrefslogtreecommitdiffstats
path: root/config/freeswitch/freeswitch_mailto.tmp
diff options
context:
space:
mode:
Diffstat (limited to 'config/freeswitch/freeswitch_mailto.tmp')
-rwxr-xr-xconfig/freeswitch/freeswitch_mailto.tmp78
1 files changed, 39 insertions, 39 deletions
diff --git a/config/freeswitch/freeswitch_mailto.tmp b/config/freeswitch/freeswitch_mailto.tmp
index 23645570..402a0524 100755
--- a/config/freeswitch/freeswitch_mailto.tmp
+++ b/config/freeswitch/freeswitch_mailto.tmp
@@ -4,7 +4,7 @@
freeswitch_mailto.php
Copyright (C) 2008 Mark J Crane
All rights reserved.
-
+
FreeSWITCH (TM)
http://www.freeswitch.org/
@@ -32,7 +32,7 @@
require_once("config.inc");
require_once("/usr/local/pkg/freeswitch.inc");
-global $config;
+global $config;
$tmp_smtphost = $config['installedpackages']['freeswitchsettings']['config'][0]['smtphost'];
$tmp_smtpsecure = $config['installedpackages']['freeswitchsettings']['config'][0]['smtpsecure']; //options "", "TLS", "SSL"
@@ -43,12 +43,12 @@ $tmp_smtppassword = $config['installedpackages']['freeswitchsettings']['config']
$tmp_smtpfrom = $config['installedpackages']['freeswitchsettings']['config'][0]['smtpfrom'];
$tmp_smtpfromname = $config['installedpackages']['freeswitchsettings']['config'][0]['smtpfromname'];
-
+
ini_set(max_execution_time,900); //15 minutes
ini_set('memory_limit', '96M');
$fd = fopen("php://stdin", "r");
-$email = file_get_contents ("php://stdin");
+$email = file_get_contents ("php://stdin");
fclose($fd);
@@ -65,8 +65,8 @@ ob_start();
$tmparray = split("\n\n", $email);
$mainheader = $tmparray[0];
$maincontent = substr($email, strlen($mainheader), strlen($email));
-
-//get the boundary
+
+//get the boundary
$tmparray = split("\n", $mainheader);
$contenttmp = $tmparray[1]; //Content-Type: multipart/mixed; boundary="XXXX_boundary_XXXX"
$tmparray = split('; ', $contenttmp); //boundary="XXXX_boundary_XXXX"
@@ -75,11 +75,11 @@ ob_start();
$boundary = $tmparray[1];
$boundary = trim($boundary,'"');
//echo "boundary: $boundary\n";
-
+
//put the main headers into an array
$mainheaderarray = split("\n", $mainheader);
//print_r($mainheaderarray);
- foreach ($mainheaderarray as $val) {
+ foreach ($mainheaderarray as $val) {
$tmparray = split(': ', $val);
//print_r($tmparray);
$var[$tmparray[0]] = trim($tmparray[1]);
@@ -87,13 +87,13 @@ ob_start();
$var['To'] = str_replace("<", "", $var['To']);
$var['To'] = str_replace(">", "", $var['To']);
-
+
echo "To: ".$var['To']."\n";
echo "From: ".$var['From']."\n";
echo "Subject: ".$var['Subject']."\n";
//print_r($var);
echo "\n\n";
-
+
// split mime type multi-part into each part
$maincontent = str_replace($boundary."--", $boundary, $maincontent);
@@ -102,7 +102,7 @@ ob_start();
// loop through each mime part
$i=0;
foreach ($tmparray as $mimepart) {
-
+
$mimearray = split("\n\n", $mimepart);
$subheader = $mimearray[0];
$headermimearray = split("\n", trim($subheader));
@@ -117,40 +117,40 @@ ob_start();
//echo "subboundary: ".$subboundary."\n";
}
}
- else {
+ else {
$tmparray = split(':', $val); //':' found
}
-
+
//print_r($tmparray);
$var[trim($tmparray[0])] = trim($tmparray[1]);
}
//print_r($var);
-
-
+
+
$contenttypearray = split(' ', $headermimearray[0]);
-
+
if ($contenttypearray[0] == "Content-Type:") {
$contenttype = trim($contenttypearray[1]);
-
+
switch ($contenttype) {
case "multipart/alternative;":
-
+
//echo "type: ".$contenttype."\n";
$content = trim(substr($mimepart, strlen($subheader), strlen($mimepart)));
-
+
$content = str_replace($subboundary."--", $subboundary, $content);
$tmpsubarray = split("--".$subboundary, $content);
foreach ($tmpsubarray as $mimesubsubpart) {
-
+
$mimesubsubarray = split("\n\n", $mimesubsubpart);
$subsubheader = $mimesubsubarray[0];
-
+
$headersubsubmimeearray = split("\n", trim($subsubheader));
$subsubcontenttypearray = split(' ', $headersubsubmimeearray[0]);
//echo "subsubcontenttypearray[0] ".$subsubcontenttypearray[0]."\n";
if ($subsubcontenttypearray[0] == "Content-Type:") {
- $subsubcontenttype = trim($subsubcontenttypearray[1]);
+ $subsubcontenttype = trim($subsubcontenttypearray[1]);
switch ($subsubcontenttype) {
case "text/plain;":
$textplain = trim(substr($mimesubsubpart, strlen($subsubheader), strlen($mimesubsubpart)));
@@ -162,51 +162,51 @@ ob_start();
break;
}
} //end if
-
+
} //end foreach
-
+
break;
case "audio/wav;":
- //echo "type: ".$contenttype."\n";
+ //echo "type: ".$contenttype."\n";
$strwav = trim(substr($mimepart, strlen($subheader), strlen($mimepart)));
//echo "\n*** begin wav ***\n".$strwav."\n*** end wav ***\n";
break;
-
- }//end switch
+
+ }//end switch
} //end if
-
- $i++;
-
+
+ $i++;
+
} //end foreach
//send the email
-
+
include "class.phpmailer.php";
include "class.smtp.php"; ; // optional, gets called from within class.phpmailer.php if not already loaded
-
+
$mail = new PHPMailer();
-
+
$mail->IsSMTP(); // set mailer to use SMTP
$mail->SMTPAuth = $tmp_smtpauth; // turn on/off SMTP authentication
$mail->Host = $tmp_smtphost;
if (strlen($tmp_smtpsecure)>0) {
$mail->SMTPSecure = $tmp_smtpsecure;
}
- if ($tmp_smtpauth) {
+ if ($tmp_smtpauth) {
$mail->Username = $tmp_smtpusername;
$mail->Password = $tmp_smtppassword;
}
-
+
$mail->From = $tmp_smtpfrom;
$mail->FromName = $tmp_smtpfromname;
$mail->Subject = $var['Subject'];
$mail->AltBody = $textplain; // optional, comment out and test
$mail->MsgHTML($texthtml);
-
-
+
+
$tmp_to = $var['To'];
$tmp_to = str_replace(";", ",", $tmp_to);
$tmp_to_array = split(",", $tmp_to);
@@ -222,10 +222,10 @@ ob_start();
$mail->AddStringAttachment(base64_decode($strwav),$filename,$encoding,$type);
}
unset($strwav);
-
+
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
- }
+ }
else {
echo "Message sent!";
}