@@ -26,6 +26,18 @@ var hostInConfig = function(plugin, connection, config, host) {
26
26
}
27
27
} ;
28
28
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
+
29
41
var checkValidMailbox = function ( next , connection , params ) {
30
42
var rcpt = params [ 0 ] ;
31
43
var address = rcpt . address ( ) ;
@@ -36,28 +48,25 @@ var checkValidMailbox = function(next, connection, params) {
36
48
var config = loadConfig ( this , connection ) ;
37
49
var returnValue ;
38
50
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 ) ;
43
56
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
+ }
46
64
} 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 ;
50
66
}
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 + ")" ) ;
56
67
} else {
57
- returnValue = "Forwarding not enabled for " + host ;
68
+ connection . transaction . notes . discard = true ;
58
69
}
59
- } else {
60
- connection . transaction . notes . discard = true ;
61
70
}
62
71
63
72
if ( returnValue ) {
0 commit comments