Skip to content

Commit 6f73a0b

Browse files
author
Joe Eaves
committed
Added better documentation for the local sender check and user-delimiter
Also improved the local sender check a little by moving it to a new function.
1 parent ad12b71 commit 6f73a0b

File tree

3 files changed

+33
-19
lines changed

3 files changed

+33
-19
lines changed

docs/plugins/jme.rcpt_to.aliases.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ jme.rcpt_to.aliases
22
========
33

44
This is a simple aliases plugin that allows chaining.
5-
There is no wildcard matching at this time, the aliases will match
6-
exactly as they are written.
5+
Aliases allow a single wildcard character '+', to fall
6+
in line with standard user-delimiter practice.
77

88
* Note: The 'official' aliases plugin has a warning about using it with the 'queue/smtp\_proxy' plugin.
99
I haven't tested this plugin with that one, so lets assume it doesn't work either.

docs/plugins/jme.rcpt_to.mailboxes.md

+5
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ before the queue. They **DO NOT** work together.
99
There is no wildcard matching for the accounts, other plugins must catch
1010
aliases/wildcards for you before the email gets here.
1111

12+
This plugin also deals with local senders. If the remote_ip of the connection
13+
matches '::' or '127.0.0.1', it will set the relaying flag. This allows Haraka
14+
to be used as a local SMTP for less configurable programs (like cron), that
15+
just talk directly to localhost:25 with no authentication.
16+
1217
Configuration
1318
-------------
1419

plugins/jme.rcpt_to.mailboxes.js

+26-17
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,18 @@ var hostInConfig = function(plugin, connection, config, host) {
2626
}
2727
};
2828

29+
var checkLocalSender = function(connection) {
30+
if ((connection.remote_ip == "127.0.0.1") ||
31+
(connection.remote_ip == "::"))
32+
{
33+
connection.relaying = true;
34+
connection.logdebug(this, "Forwarding allowed for " +
35+
connection.remote_ip + " (to " + address + ")");
36+
return true;
37+
}
38+
return false;
39+
}
40+
2941
var checkValidMailbox = function(next, connection, params) {
3042
var rcpt = params[0];
3143
var address = rcpt.address();
@@ -36,28 +48,25 @@ var checkValidMailbox = function(next, connection, params) {
3648
var config = loadConfig(this, connection);
3749
var returnValue;
3850

39-
if(config && !connection.transaction.notes.pipe) {
40-
if(hostInConfig(this, connection, config, host)) {
41-
config = config[host];
42-
connection.loginfo(this, "Checking account for: " + address);
51+
if(!checkLocalSender(connection)) {
52+
if(config && !connection.transaction.notes.pipe) {
53+
if(hostInConfig(this, connection, config, host)) {
54+
config = config[host];
55+
connection.loginfo(this, "Checking account for: " + address);
4356

44-
if (config[user]) {
45-
connection.logdebug(this, "User " + address + " exists");
57+
if (config[user]) {
58+
connection.logdebug(this, "User " + address + " exists");
59+
} else {
60+
// Maybe we should bounce instead?
61+
connection.logdebug(this, "User " + address + " does not exist");
62+
returnValue = "User does not exist!";
63+
}
4664
} else {
47-
// Maybe we should bounce instead?
48-
connection.logdebug(this, "User " + address + " does not exist");
49-
returnValue = "User does not exist!";
65+
returnValue = "Forwarding not enabled for " + host;
5066
}
51-
} else if ((connection.remote_ip == "127.0.0.1") ||
52-
(connection.remote_ip == "::")) {
53-
connection.relaying = true;
54-
connection.logdebug(this, "Forwarding allowed for " +
55-
connection.remote_ip + " (to " + address + ")");
5667
} else {
57-
returnValue = "Forwarding not enabled for " + host;
68+
connection.transaction.notes.discard = true;
5869
}
59-
} else {
60-
connection.transaction.notes.discard = true;
6170
}
6271

6372
if(returnValue) {

0 commit comments

Comments
 (0)