Skip to content

Commit 28bdf6c

Browse files
committed
Release with with all the changes of the last 10 months
1 parent 1df8e82 commit 28bdf6c

File tree

6 files changed

+57
-36
lines changed

6 files changed

+57
-36
lines changed

Changes.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
# 1.8.5 - 2022-xx-xx
1+
# 1.8.5 - 2023-03-05
22

3+
- New & Breaking change: Check for too many emails has been changed to containing the exclude and/or include value. Read the README.
34
- New: Define attachment names (entire name or part of the name) and it will be blocked. Check the mongodb.ini or README.
45
- Checking the limit of the message is done now only for incoming messages.
56
- Attachments file names that start with a "." (dot) are now saved with the checksum and extension as file name.
7+
- Fix: Check for too many emails within a specific time did not work with include.
68

79
# 1.8.4 - 2022-05-08
810

@@ -59,7 +61,7 @@
5961
# 1.6.5 - 2020-10-18
6062

6163
- NEW: We've added an option to limit incoming emails. Please see README
62-
- We are now creating indexes for our collections
64+
- We are now creating indexes for our collections
6365
- Returning a "DENY" if the message is larger than 16MB
6466
- Returning a "DENY" if the message cannot be parsed
6567
- Updated libraries
@@ -85,7 +87,7 @@
8587

8688
- You can now use a mongodb:// connection string with the new string value
8789
- There is now a new "limit" option as you cannot insert more that 16 MB documents into MongoDB
88-
- You can now send back emails to the sender on limits, parsing, and insert errors
90+
- You can now send back emails to the sender on limits, parsing, and insert errors
8991
- Improved performance for parsing inline images
9092
- Added custom content type to extend what attachments Haraka should accept as valid files. Otherwise the attachment is renamed to (filename).txt
9193
- Removed some content types from the default reject string
@@ -150,7 +152,7 @@
150152

151153
# 1.4.8 - 2019-12-05
152154

153-
- The filename of files within a winmail.dat are now cleaned up as well (surprisingly a lot of people are still sending those)
155+
- The filename of files within a winmail.dat are now cleaned up as well (surprisingly a lot of people are still sending those)
154156

155157
# 1.4.7 - 2019-12-04
156158

README.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ Copy the mongodb.ini from the config directory (haraka-plugin-mongodb/config) to
3838

3939
Provide your credentials to connect to your MongoDB instance.
4040

41-
As of version 1.6.2 you can also define a mongodb connection string directly using the "string" value. This has to be a valid [mongodb connection string](https://docs.mongodb.com/manual/reference/connection-string). If you define a connection string, only the connection string will be used for the connection.
41+
As of version 1.6.2 you can also define a mongodb connection string directly using the "string" value. This has to be a valid [mongodb connection string](https://docs.mongodb.com/manual/reference/connection-string). If you define a connection string, only the connection string will be used for the connection.
4242

43-
Please note that the mongodb connection is used for both the delivery and the queue. If you want to store the queue in another database you should use a separate queue and a delivery instance.
43+
Please note that the mongodb connection is used for both the delivery and the queue. If you want to store the queue in another database you should use a separate queue and a delivery instance.
4444

4545
## Section: Collections
4646

@@ -86,9 +86,20 @@ Enter your SMTP server values and FROM, CC, and BCC for sending an alert email t
8686

8787
Enabling the limits for incoming emails will check the FROM and the TO email-address of incoming email and send back a "softdeny" if found. The time amount is set in the "timeout_seconds" setting. By default this is set to 10 seconds. In our experience, we've seen that this will throttle most automated systems, while emails from users are coming in without delays.
8888

89-
Use the "exclude" (empty array) settings to never throttle emails from a certain domain.
89+
Use the "exclude" settings to never throttle emails from a certain domain.
9090

91-
As of 1.7.0 you can also use the "include" (empty array) setting to only include certain domains in the check. An empty array means to check for all incoming emails, one or many values mean to only check for those domains.
91+
92+
---
93+
### Breaking change as of 1.8.5
94+
95+
The exclude and include values check if the word is found within the senders email address. Previously, it was only checking the email domain. This allows you to exclude certain words and/or include words. The default config file now includes some sane values to check now (though, as long as the limit check is disabled nothing it will not check for anything).
96+
97+
Please also note, that the format of the exclude and include params has changed! If you use the limit check, please change your config values first.
98+
99+
---
100+
101+
102+
As of 1.7.0 you can also use the "include" setting to only include certain domains in the check. An empty array means to check for all incoming emails, one or many values mean to only check for those domains.
92103

93104
As of 1.8.0 there is a new parameter called "db" that lets you use Redis as an alternative to MongoDB. This is helpful if you get thousands of emails and want to save on the constant MongoDB connections. Besides, the MongoDB TTL is not accurate enough and Redis is made for such a use case. Set db=redis to use Redis instead of db=mongodb.
94105

config/max_data_line_length

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3000

config/mongodb.ini

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,37 @@ bcc=
7777
; Limit incoming messages. Please see the README for instructions
7878
[limits]
7979
incoming=no
80-
incoming_collection=limit_incoming
80+
8181
; Limit in seconds
8282
incoming_seconds=30
83-
; Domains you want to exclude from the limits check
84-
exclude=['helpmonks.com','helpmonks.net','helpmonks.org','sendmonks.net','sendmonks.com','razuna.com','razuna.org']
85-
; Domains that should be INCLUDED in the limits check (when left as an empty array it will check every email)
86-
include=[]
83+
84+
; Strings that should be excluded from the limits check
85+
exclude[] = helpmonks
86+
exclude[] = sendmonks
87+
exclude[] = razuna
88+
89+
; String that should be included in the limits check
90+
include[] = monitor
91+
include[] = notification
92+
include[] = java
93+
include[] = noreply
94+
include[] = notreply
95+
include[] = no-reply
96+
include[] = not-reply
97+
include[] = deployment
98+
include[] = notifier
99+
include[] = root
100+
include[] = alert
101+
include[] = uptime
102+
include[] = robot
103+
include[] = opsgenie
104+
87105
; Set the database to be used. Either "mongodb" or "redis"
88106
db=redis
89107

108+
; Set the collection to be used if you use mongodb
109+
incoming_collection=limit_incoming
110+
90111
; Redis Credentials
91112
; Used for the limit incoming option above
92113
[redis]

index.js

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -688,35 +688,21 @@ function _limitIncoming(plugin, email_headers, cb) {
688688
// Make sure we got the email address
689689
_from = _from.map(t => t.address || t)[0];
690690
// Clean from
691-
_from = _from.replace(/<|>/gm, '');
692-
// TO
693-
_to = _to.map(t => t.address || t);
691+
_from = _from.replace(/<|>/gm, '').toLowerCase();
694692
// Check excludes
695-
var _from_split = _from.split('@');
696-
// plugin.lognotice("_from_split", _from_split);
697-
if ( plugin.cfg.limits.exclude.includes(_from_split[1]) ) {
698-
// plugin.lognotice("Exclude: ", _from);
693+
var _limit_exclude = plugin.cfg.limits.exclude || [];
694+
var _found_exlude_value = _limit_exclude.find(n => _from.includes(n));
695+
if (_found_exlude_value) {
699696
return cb(null, null);
700697
}
701698
// Check include
702-
var _check = true;
703699
var _limit_include = plugin.cfg.limits.include || [];
704-
// _limit_include = JSON.parse(_limit_include);
705-
// Include has values
706-
if ( _limit_include.length && _limit_include.includes(_from_split[1]) ) {
707-
_check = true;
708-
}
709-
else {
710-
_check = false;
711-
}
712-
// Include is empty
713-
if ( !_limit_include.length ) {
714-
_check = true;
715-
}
716-
// Return depending on check
717-
if (!_check) {
700+
var _found_include_value = _limit_include.find(n => _from.includes(n));
701+
if (!_found_include_value) {
718702
return cb(null, null);
719703
}
704+
// TO
705+
_to = _to.map(t => t.address || t);
720706
// Which db
721707
var _is_mongodb = plugin.cfg.limits.db === 'mongodb' ? true : false;
722708
// Loop

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "haraka-plugin-mongodb",
3-
"version": "1.8.4",
3+
"version": "1.8.5",
44
"description": "Haraka plugin that stores emails in MongoDb. Additionally, stores reports on delivery.",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)