mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2026-01-06 11:43:50 +00:00
fix send_email function for multi-part addresses
The send_email function wasn't successfully parsing ; or , separated email address lists. I simplified it's processing. While I was at it I removed the "valid email" check from email_test.php because that step is already being done in the send_email function that is called and it safely returns the appropriate error. I would have had to rewrite that function to handle the multiple email lists otherwise.
This commit is contained in:
@@ -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 "<script>display_message('".$text['message-invalid_token']."', 'negative');</script>";
|
||||
echo "<center>\n";
|
||||
echo $text['message-invalid_token'];
|
||||
echo " <br><br>\n";
|
||||
echo " <input type='button' class='btn' style='margin-top: 15px;' value='".$text['button-close']."' onclick=\"$('#test_result_layer').fadeOut(200);\">\n";
|
||||
echo "</center>\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 "<script>display_message('".$text['message-invalid_token']."', 'negative');</script>";
|
||||
echo "<center>\n";
|
||||
echo $text['message-invalid_token'];
|
||||
echo " <br><br>\n";
|
||||
echo " <input type='button' class='btn' style='margin-top: 15px;' value='".$text['button-close']."' onclick=\"$('#test_result_layer').fadeOut(200);\">\n";
|
||||
echo "</center>\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
$recipient = check_str($_POST['to']);
|
||||
|
||||
echo "<b>".$text['header-settings']."</b>\n";
|
||||
echo "<br><br>\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 "<a href='../../core/default_settings/default_setting_edit.php?id=".$uuid."' target='_blank'>".$name.'</a>: '.$value."<br>\n";
|
||||
}
|
||||
|
||||
$recipient = check_str($_POST['to']);
|
||||
|
||||
echo "<b>".$text['header-settings']."</b>\n";
|
||||
echo "<br><br>\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 "<a href='../../core/default_settings/default_setting_edit.php?id=".$uuid."' target='_blank'>".$name.'</a>: '.$value."<br>\n";
|
||||
}
|
||||
else {
|
||||
echo $name.': '.$value."<br>\n";
|
||||
}
|
||||
else {
|
||||
echo $name.': '.$value."<br>\n";
|
||||
}
|
||||
}
|
||||
echo "<br><br>\n";
|
||||
|
||||
echo "<b>".$text['header-connection']."</b>\n";
|
||||
echo "<br><br>\n";
|
||||
|
||||
$eml_body = "<b>Test Message</b><br /><br />\n";
|
||||
$eml_body .= "This message is a test of the SMTP settings configured within your PBX.<br />\n";
|
||||
$eml_body .= "If you received this message, your current SMTP settings are valid.<br /><br />\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 "<br><br>\n";
|
||||
|
||||
echo "<b>".$text['header-result']."</b>\n";
|
||||
echo "<br><br>\n";
|
||||
echo $sent ? "Message Sent Successfully<br>Receipient: <a href='mailto:".$recipient."'>".$recipient."</a>" : "Message Failed...<br>".$eml_error;
|
||||
|
||||
}
|
||||
else {
|
||||
echo "Error: Invalid Recipient Address";
|
||||
}
|
||||
echo "<br><br>\n";
|
||||
|
||||
echo "<b>".$text['header-connection']."</b>\n";
|
||||
echo "<br><br>\n";
|
||||
|
||||
$eml_body = "<b>Test Message</b><br /><br />\n";
|
||||
$eml_body .= "This message is a test of the SMTP settings configured within your PBX.<br />\n";
|
||||
$eml_body .= "If you received this message, your current SMTP settings are valid.<br /><br />\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 "<br><br>\n";
|
||||
|
||||
echo "<b>".$text['header-result']."</b>\n";
|
||||
echo "<br><br>\n";
|
||||
echo $sent ? "Message Sent Successfully<br>Receipient: <a href='mailto:".$recipient."'>".$recipient."</a>" : "Message Failed...<br>".$eml_error;
|
||||
|
||||
|
||||
echo "<br>\n";
|
||||
echo "<center>\n";
|
||||
|
||||
Reference in New Issue
Block a user