parent
c5be2b27e9
commit
6d7b3a9249
|
|
@ -122,7 +122,11 @@ if (!empty($result) && @sizeof($result) != 0) {
|
||||||
continue; // try next account
|
continue; // try next account
|
||||||
}
|
}
|
||||||
|
|
||||||
//get emails
|
//send more log information
|
||||||
|
echo " Connection: ".$fax_email_connection."\n";
|
||||||
|
echo " Required Subject: [".$fax_email_outbound_subject_tag."]\n";
|
||||||
|
|
||||||
|
//get emails from imap
|
||||||
if ($emails = imap_search($connection, "SUBJECT \"[".$fax_email_outbound_subject_tag."]\"", SE_UID)) {
|
if ($emails = imap_search($connection, "SUBJECT \"[".$fax_email_outbound_subject_tag."]\"", SE_UID)) {
|
||||||
|
|
||||||
//get authorized sender(s)
|
//get authorized sender(s)
|
||||||
|
|
@ -133,7 +137,13 @@ if (!empty($result) && @sizeof($result) != 0) {
|
||||||
$authorized_senders[] = $fax_email_outbound_authorized_senders;
|
$authorized_senders[] = $fax_email_outbound_authorized_senders;
|
||||||
}
|
}
|
||||||
|
|
||||||
sort($emails); // oldest first
|
//sort the emails as oldest first
|
||||||
|
sort($emails);
|
||||||
|
|
||||||
|
//send information to the console
|
||||||
|
echo " Number of Emails: ".count($emails)."\n";
|
||||||
|
|
||||||
|
//process each email
|
||||||
foreach ($emails as $email_id) {
|
foreach ($emails as $email_id) {
|
||||||
//get email meta data
|
//get email meta data
|
||||||
$metadata = object_to_array(imap_fetch_overview($connection, $email_id, FT_UID));
|
$metadata = object_to_array(imap_fetch_overview($connection, $email_id, FT_UID));
|
||||||
|
|
@ -157,7 +167,7 @@ if (!empty($result) && @sizeof($result) != 0) {
|
||||||
$sender_authorized = in_array($sender_email, $authorized_senders) || in_array($sender_domain, $authorized_senders) ? true : false;
|
$sender_authorized = in_array($sender_email, $authorized_senders) || in_array($sender_domain, $authorized_senders) ? true : false;
|
||||||
if ($sender_authorized) {
|
if ($sender_authorized) {
|
||||||
//debug info
|
//debug info
|
||||||
//echo "authorized\n";
|
echo " Sender Authorized: ".$sender_email."\n";
|
||||||
|
|
||||||
//add multi-lingual support
|
//add multi-lingual support
|
||||||
$language = new text;
|
$language = new text;
|
||||||
|
|
@ -187,13 +197,13 @@ if (!empty($result) && @sizeof($result) != 0) {
|
||||||
$fax_message = '';
|
$fax_message = '';
|
||||||
|
|
||||||
//Debug print
|
//Debug print
|
||||||
print('attachments:' . "\n");
|
print(' Attachments:' . "\n");
|
||||||
foreach ($message['attachments'] as $attachment){
|
foreach ($message['attachments'] as $attachment){
|
||||||
print(' - ' . $attachment['type'] . ' - ' . $attachment['name'] . ': ' . $attachment['size'] . ' disposition: ' . $attachment['disposition'] . "\n");
|
print(' ' . $attachment['type'] . ' - ' . $attachment['name'] . ': ' . $attachment['size'] . ' disposition: ' . $attachment['disposition'] . "\n");
|
||||||
}
|
}
|
||||||
print('messages:' . "\n");
|
print(' Messages:' . "\n");
|
||||||
foreach ($message['messages'] as $msg){
|
foreach ($message['messages'] as $msg){
|
||||||
print(' - ' . $msg['type'] . ' - ' . $msg['size'] . "\n");
|
print(' ' . $msg['type'] . ' - ' . $msg['size'] . "\n");
|
||||||
// print($msg['data']);
|
// print($msg['data']);
|
||||||
// print("\n--------------------------------------------------------\n");
|
// print("\n--------------------------------------------------------\n");
|
||||||
}
|
}
|
||||||
|
|
@ -219,12 +229,15 @@ if (!empty($result) && @sizeof($result) != 0) {
|
||||||
$attachments = $message['attachments'];
|
$attachments = $message['attachments'];
|
||||||
if (sizeof($attachments) > 0) {
|
if (sizeof($attachments) > 0) {
|
||||||
foreach ($attachments as $attachment) {
|
foreach ($attachments as $attachment) {
|
||||||
|
//get the fax file extension
|
||||||
$fax_file_extension = pathinfo($attachment['name'], PATHINFO_EXTENSION);
|
$fax_file_extension = pathinfo($attachment['name'], PATHINFO_EXTENSION);
|
||||||
|
|
||||||
//block unknown files
|
//block unknown files
|
||||||
if ($fax_file_extension == '') {continue; }
|
if ($fax_file_extension == '') {continue; }
|
||||||
|
|
||||||
//block unauthorized files
|
//block unauthorized files
|
||||||
if (!$fax_allowed_extension['.' . $fax_file_extension]) { continue; }
|
if (!$fax_allowed_extension['.' . $fax_file_extension]) { continue; }
|
||||||
|
|
||||||
//support only attachments
|
//support only attachments
|
||||||
//if($attachment['disposition'] != 'attachment'){ continue; }
|
//if($attachment['disposition'] != 'attachment'){ continue; }
|
||||||
|
|
||||||
|
|
@ -242,16 +255,14 @@ if (!empty($result) && @sizeof($result) != 0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
//Debug print
|
//Debug print
|
||||||
print('***********************' . "\n");
|
print(' FAX Message:' . "\n");
|
||||||
print('fax message:' . "\n");
|
print(' Message Length: ' . strlen($fax_message) . "\n");
|
||||||
print(' - length: ' . strlen($fax_message) . "\n");
|
|
||||||
if (isset($emailed_files['name'])) {
|
if (isset($emailed_files['name'])) {
|
||||||
print('fax files [' . sizeof($emailed_files['name']) . ']:' . "\n");
|
print(' FAX Files [' . sizeof($emailed_files['name']) . ']:' . "\n");
|
||||||
for($i = 0; $i < sizeof($emailed_files['name']);++$i){
|
for($i = 0; $i < sizeof($emailed_files['name']);++$i){
|
||||||
print(' - ' . $emailed_files['name'][$i] . ' - ' . $emailed_files['size'][$i] . "\n");
|
print(' ' . $emailed_files['name'][$i] . ' - ' . $emailed_files['size'][$i] . "\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print('***********************' . "\n");
|
|
||||||
|
|
||||||
//send fax
|
//send fax
|
||||||
$cwd = getcwd();
|
$cwd = getcwd();
|
||||||
|
|
@ -278,6 +289,9 @@ if (!empty($result) && @sizeof($result) != 0) {
|
||||||
|
|
||||||
//close account connection
|
//close account connection
|
||||||
imap_close($connection);
|
imap_close($connection);
|
||||||
|
|
||||||
|
//add a line feed
|
||||||
|
echo "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue