-
-
Notifications
You must be signed in to change notification settings - Fork 405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Emails sent multiple times to the same address can be rejected #4543
Comments
Technically, we can't de-dupe that situation. Both are valid independent email addresses according to the RFC. |
Ouch. Okay, maybe we issue a warning then? I was able to cleanup the issue (In thold), and I plan on disabling legacy notifications.
|
Taken from https://stackoverflow.com/a/9808332/697159
|
Maybe we ignore the RFC on that one since most systems do these days. But we need to make sure it's documented. |
I think we should. It's a minor thing. Looking at the code |
How does this look? diff --git a/lib/functions.php b/lib/functions.php
index 08b383488..447020ccd 100644
--- a/lib/functions.php
+++ b/lib/functions.php
@@ -4728,7 +4728,7 @@ function parse_email_details($emails, $max_records = 0, $details = array()) {
foreach($emails as $email) {
$email_array = split_emaildetail($email);
- $details[] = $email_array;
+ $details[$email_array['email']] = $email_array;
}
} else {
$has_name = array_key_exists('name', $check_email);
@@ -4742,13 +4742,14 @@ function parse_email_details($emails, $max_records = 0, $details = array()) {
$email = array_key_exists(0, $check_email) ? $check_email[0] : '';
}
- $details[] = array('name' => trim($name), 'email' => trim($email));
+ $details[trim(strtolower($email))] = array('name' => trim($name), 'email' => trim(strtolower($email)));
}
}
}
if ($max_records == 1) {
- $results = count($details) ? $details[0] : array();
+ $index = array_keys($details)[0];
+ $results = count($details) ? $details[$index] : array();
} elseif ($max_records != 0 && $max_records < count($details)) {
$results = array();
foreach ($details as $d) {
@@ -4787,7 +4788,7 @@ function split_emaildetail($email) {
$rname = $email[1];
}
- return array('name' => $rname, 'email' => $rmail);
+ return array('name' => $rname, 'email' => strtolower($rmail));
}
function create_emailtext($e) { |
I would personally just use reset($details) to get the first item. Saves messing around getting the keys to get the first element. |
Also, I would only set the element once, but report duplicates if there is a difference in the values? For example, if you have the same email but different names.... |
Interesting. Let me think about it. |
- Some Email systems reject sending email if emails are duplicated in a send request. Cacti should deduplicate them - I did not fix the duplicate name issue. We can put that into the backlog as a new issue. - Used reset() to shortcut getting the first value - All Emails converted to lower case regardless of RFC as there is some debate there.
Okay, used reset, but not detecting the duplicate name for now. We can put that into the backlog. |
Describe the bug
We recently got into a mailer issue the other day where we had the same Email in a Notification list, and the same Email in a
notification_extra
using an upper case email. When calling the mailer with this condition, the upstream mail services rejected the Email since it had duplicated Email addresses.EMAIL@domain.com,email@domain.com
That example was rejected upstream.
Expected behavior
Cacti should per-process the Email list, convert the Emails to lower case, and de-duplicate them prior to sending to the upstream mail service.
The text was updated successfully, but these errors were encountered: