From cb1d126c44ec2dcd2d2c5c118195e285c13b55d3 Mon Sep 17 00:00:00 2001 From: mcrane Date: Mon, 13 Jul 2009 16:10:08 -0600 Subject: FreeSWITCH add new dev package to seperate development from release. --- config/freeswitch_dev/freeswitch_mailto.tmp | 243 ++++++++++++++++++++++++++++ 1 file changed, 243 insertions(+) create mode 100644 config/freeswitch_dev/freeswitch_mailto.tmp (limited to 'config/freeswitch_dev/freeswitch_mailto.tmp') diff --git a/config/freeswitch_dev/freeswitch_mailto.tmp b/config/freeswitch_dev/freeswitch_mailto.tmp new file mode 100644 index 00000000..fa27ff68 --- /dev/null +++ b/config/freeswitch_dev/freeswitch_mailto.tmp @@ -0,0 +1,243 @@ +", "", $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); + $tmparray = split("--".$boundary, $maincontent); + +// loop through each mime part + $i=0; + foreach ($tmparray as $mimepart) { + + $mimearray = split("\n\n", $mimepart); + $subheader = $mimearray[0]; + $headermimearray = split("\n", trim($subheader)); + + $x=0; + foreach ($headermimearray as $val) { + if(stristr($val, ':') === FALSE) { + $tmparray = split('=', $val); //':' not found + if (trim($tmparray[0]) == "boundary") { + $subboundary = $tmparray[1]; + $subboundary = trim($subboundary,'"'); + //echo "subboundary: ".$subboundary."\n"; + } + } + 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]); + switch ($subsubcontenttype) { + case "text/plain;": + $textplain = trim(substr($mimesubsubpart, strlen($subsubheader), strlen($mimesubsubpart))); + //echo "text/plain: $textplain\n"; + break; + case "text/html;": + $texthtml = trim(substr($mimesubsubpart, strlen($subsubheader), strlen($mimesubsubpart))); + //echo "text/html: $texthtml\n"; + break; + } + } //end if + + + } //end foreach + + break; + case "audio/wav;": + //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 if + + $i++; + + } //end foreach + + +//send the email + + include "/usr/local/www/packages/freeswitch/class.phpmailer.php"; + include "/usr/local/www/packages/freeswitch/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 + if ($tmp_smtpauth == "true") { + $mail->SMTPAuth = $tmp_smtpauth; // turn on/off SMTP authentication + } + $mail->Host = $tmp_smtphost; + if (strlen($tmp_smtpsecure)>0) { + $mail->SMTPSecure = $tmp_smtpsecure; + } + if ($tmp_smtpusername) { + $mail->Username = $tmp_smtpusername; + $mail->Password = $tmp_smtppassword; + } + $mail->SMTPDebug = 2; + + + $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); + foreach($tmp_to_array as $tmp_to_row) { + if (strlen($tmp_to_row) > 0) { + $mail->AddAddress($tmp_to_row); + } + } + + if (strlen($strwav) > 0) { + //$mail->AddAttachment("/usr/local/freeswitch/data/domain/example.wav"); // attachment + $filename='voicemail.wav'; $encoding = "base64"; $type = "audio/wav"; + $mail->AddStringAttachment(base64_decode($strwav),$filename,$encoding,$type); + } + unset($strwav); + + if(!$mail->Send()) { + echo "Mailer Error: " . $mail->ErrorInfo; + } + else { + echo "Message sent!"; + } + + +$content = ob_get_contents(); //get the output from the buffer +ob_end_clean(); //clean the buffer + +fwrite($fp, $content); +fclose($fp); + +?> \ No newline at end of file -- cgit v1.2.3