Merge pull request #5841 from demonspork/send_email-multipart-fix

fix send_email function for multi-part addresses
This commit is contained in:
FusionPBX 2021-03-19 18:28:34 -06:00 committed by GitHub
commit ae28718368
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 66 additions and 83 deletions

View File

@ -35,7 +35,6 @@
$text = $language->get();
//send email
if (valid_email($_POST['to'])) {
//validate the token
$token = new token;
@ -88,10 +87,6 @@
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>\n";
echo "<center>\n";

View File

@ -1411,12 +1411,9 @@ 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
@ -1439,16 +1436,7 @@ function number_pad($number,$n) {
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;
}
}
if (is_array($eml_attachments) && sizeof($eml_attachments) > 0) {
foreach ($eml_attachments as $attachment) {