diff --git a/app/email_logs/email_test.php b/app/email_logs/email_test.php
index e5431dc1f6..76187f2e00 100644
--- a/app/email_logs/email_test.php
+++ b/app/email_logs/email_test.php
@@ -35,63 +35,58 @@
$text = $language->get();
//send email
- if (valid_email($_POST['to'])) {
- //validate the token
- $token = new token;
- if (!$token->validate('/app/email_logs/email_logs.php')) {
- //message::add($text['message-invalid_token'],'negative');
- echo "";
- echo "
\n";
- echo $text['message-invalid_token'];
- echo " \n";
- echo " \n";
- echo " \n";
- exit;
+ //validate the token
+ $token = new token;
+ if (!$token->validate('/app/email_logs/email_logs.php')) {
+ //message::add($text['message-invalid_token'],'negative');
+ echo "";
+ echo "\n";
+ echo $text['message-invalid_token'];
+ echo " \n";
+ echo " \n";
+ echo " \n";
+ exit;
+ }
+
+ $recipient = check_str($_POST['to']);
+
+ echo "".$text['header-settings']." \n";
+ echo " \n";
+ ksort($_SESSION['email']);
+ foreach ($_SESSION['email'] as $name => $setting) {
+ foreach ($setting as $type => $value) {
+ if ($type == 'uuid') { $uuid = $value; continue; }
+ if ($name == 'smtp_password') { $value = '[REDACTED]'; }
+ if (permission_exists('default_setting_edit')) {
+ echo "".$name.' : '.$value." \n";
}
-
- $recipient = check_str($_POST['to']);
-
- echo "".$text['header-settings']." \n";
- echo " \n";
- ksort($_SESSION['email']);
- foreach ($_SESSION['email'] as $name => $setting) {
- foreach ($setting as $type => $value) {
- if ($type == 'uuid') { $uuid = $value; continue; }
- if ($name == 'smtp_password') { $value = '[REDACTED]'; }
- if (permission_exists('default_setting_edit')) {
- echo "".$name.' : '.$value." \n";
- }
- else {
- echo $name.': '.$value." \n";
- }
+ else {
+ echo $name.': '.$value." \n";
}
}
- echo " \n";
-
- echo "".$text['header-connection']." \n";
- echo " \n";
-
- $eml_body = "Test Message \n";
- $eml_body .= "This message is a test of the SMTP settings configured within your PBX. \n";
- $eml_body .= "If you received this message, your current SMTP settings are valid. \n";
-
- ob_start();
- $sent = !send_email($recipient, 'Test Message', $eml_body, $eml_error, null, null, 3, 3) ? false : true;
- $response = ob_get_clean();
-
- echo $response;
-
- echo " \n";
-
- echo "".$text['header-result']." \n";
- echo " \n";
- echo $sent ? "Message Sent Successfully Receipient: ".$recipient." " : "Message Failed... ".$eml_error;
-
- }
- else {
- echo "Error: Invalid Recipient Address";
}
+ echo " \n";
+
+ echo "".$text['header-connection']." \n";
+ echo " \n";
+
+ $eml_body = "Test Message \n";
+ $eml_body .= "This message is a test of the SMTP settings configured within your PBX. \n";
+ $eml_body .= "If you received this message, your current SMTP settings are valid. \n";
+
+ ob_start();
+ $sent = !send_email($recipient, 'Test Message', $eml_body, $eml_error, null, null, 3, 3) ? false : true;
+ $response = ob_get_clean();
+
+ echo $response;
+
+ echo " \n";
+
+ echo "".$text['header-result']." \n";
+ echo " \n";
+ echo $sent ? "Message Sent Successfully Receipient: ".$recipient." " : "Message Failed... ".$eml_error;
+
echo " \n";
echo "\n";
diff --git a/resources/functions.php b/resources/functions.php
index daf5e4c4ff..0ed1240d45 100644
--- a/resources/functions.php
+++ b/resources/functions.php
@@ -1411,45 +1411,33 @@ function number_pad($number,$n) {
if (!is_array($eml_recipients)) { // must be a single or delimited recipient address(s)
$eml_recipients = str_replace(' ', '', $eml_recipients);
- if (substr_count(',', $eml_recipients)) { $delim = ','; }
- if (substr_count(';', $eml_recipients)) { $delim = ';'; }
- if ($delim) { $eml_recipients = explode($delim, $eml_recipients); } // delimiter found, convert to array of addresses
+ $eml_recipients = str_replace(array(';',','), ' ', $eml_recipients);
+ $eml_recipients = explode(' ', $eml_recipients); // convert to array of addresses
}
-
- if (is_array($eml_recipients)) { // check if multiple recipients
- foreach ($eml_recipients as $eml_recipient) {
- if (is_array($eml_recipient)) { // check if each recipient has multiple fields
- if ($eml_recipient["address"] != '' && preg_match($regexp, $eml_recipient["address"]) == 1) { // check if valid address
- switch ($eml_recipient["delivery"]) {
- case "cc" : $mail -> AddCC($eml_recipient["address"], ($eml_recipient["name"]) ? $eml_recipient["name"] : $eml_recipient["address"]); break;
- case "bcc" : $mail -> AddBCC($eml_recipient["address"], ($eml_recipient["name"]) ? $eml_recipient["name"] : $eml_recipient["address"]); break;
- default : $mail -> AddAddress($eml_recipient["address"], ($eml_recipient["name"]) ? $eml_recipient["name"] : $eml_recipient["address"]);
- }
- $address_found = true;
+ foreach ($eml_recipients as $eml_recipient) {
+ if (is_array($eml_recipient)) { // check if each recipient has multiple fields
+ if ($eml_recipient["address"] != '' && preg_match($regexp, $eml_recipient["address"]) == 1) { // check if valid address
+ switch ($eml_recipient["delivery"]) {
+ case "cc" : $mail -> AddCC($eml_recipient["address"], ($eml_recipient["name"]) ? $eml_recipient["name"] : $eml_recipient["address"]); break;
+ case "bcc" : $mail -> AddBCC($eml_recipient["address"], ($eml_recipient["name"]) ? $eml_recipient["name"] : $eml_recipient["address"]); break;
+ default : $mail -> AddAddress($eml_recipient["address"], ($eml_recipient["name"]) ? $eml_recipient["name"] : $eml_recipient["address"]);
}
- }
- else if ($eml_recipient != '' && preg_match($regexp, $eml_recipient) == 1) { // check if recipient value is simply (only) an address
- $mail -> AddAddress($eml_recipient);
$address_found = true;
}
}
-
- if (!$address_found) {
- $eml_error = "No valid e-mail address provided.";
- return false;
- }
-
- }
- else { // just a single e-mail address found, not an array of addresses
- if ($eml_recipients != '' && preg_match($regexp, $eml_recipients) == 1) { // check if email syntax is valid
- $mail -> AddAddress($eml_recipients);
- }
- else {
- $eml_error = "No valid e-mail address provided.";
- return false;
+ else if ($eml_recipient != '' && preg_match($regexp, $eml_recipient) == 1) { // check if recipient value is simply (only) an address
+ $mail -> AddAddress($eml_recipient);
+ $address_found = true;
}
}
+ if (!$address_found) {
+ $eml_error = "No valid e-mail address provided.";
+ return false;
+ }
+
+
+
if (is_array($eml_attachments) && sizeof($eml_attachments) > 0) {
foreach ($eml_attachments as $attachment) {
$attachment['name'] = $attachment['name'] != '' ? $attachment['name'] : basename($attachment['value']);