Hey Jason,

SPF check can be found in smtpserver.xml.

This is the sample:

<smtpservers>
    <smtpserver>
        <!-- some other stuff -->
        <handlerchain>
            <!-- stuff -->

            <!-- This command handler can be used to reject emails with not match the SPF record of the sender domain -->             <!-- If checkAuthNetworks is set to true sender domain will be checked also for clients that -->
            <!-- are allowed to relay. Default is false. -->
            <!--
            <handler class="org.apache.james.smtpserver.fastfail.SPFHandler">
                <blockSoftFail>false</blockSoftFail>
                <blockPermError>true</blockPermError>
            </handler>
            -->

            <!-- stuff -->
        </handlerchain>
    </smtpserver>
</smtpservers>

I tried to use it - but it somewhat fails with wired error logs that it somehow can't split the domain part from incoming mail-sender and throws away all incoming mail. Guess that's a bug and need further testing - but it's there and you can try it. If it works - fine. If it doesn't - file a bug report.

About DKIM - I remember to have seen some lines about it - but as I checked I couldn't find it anymore, only SMIME encryption and signature. I also don't know if an additional lib is required or if anything is already in current master branch - I don't use DKIM, although it highly increases security and decrease false positive spam checks. Maybe worth I'll have a look into it. But I guess some other experienced users or members of the dev team could help along with DKIM.

so far,

Matt

Am 05.07.2019 um 11:23 schrieb Jason Tjankilisan:
Hiya matt,

About the DKIM and SPF, either I minsunderstood what I read from your mail or 
have a very limited knowledge about the conf files, but I didn’t found anything 
DKIM Related after reading it short in the smtpserver.xml and mailetconfig.xml. 
I thought the jdkim need to be downloaded from the james website and then 
inserted into james/lib.

But for this problem, im gonna make a new thread later if I still hit a dead 
end (so not to mislead the title). Its too soon for me to comment about this 
without trying and reading about it first.

Thank you also for the list of IP of spamming. Gonna try to ask permission to 
update the iptables.

Sorry for any wrong word, and thank you for the help.

Sincerely, Jason

Sent from Mail for Windows 10

From: cryptearth
Sent: Friday, July 5, 2019 3:07 PM
To: server-user@james.apache.org
Subject: Re: About Custom Mailet Configuration

Hey Jason,

glad to hear you could it got to work.

About DKIM: You don't need to implement that yourself - when you look
through smtpserver.xml and mailetcontainer.xml you'll find blocks for it
- you just have to enable them and provide needed data. SPF is some DNS
setting - a checker is also already provided - but I not got it to work
as somehow when try to use the provided one it fails. Maybe this is
fixed in 3.4.x - have to check.

ANT isn't needed to build a mailet - also unpacking the lib isn't needed
- a simple call the javac with classpath set to james/lib/* is ok. nvm

About the last one: OH, those spammer networks - here's a list I got so
far - and it's still grow each day. I just use iptables to complete
block them:

5.188.52.254
37.49.230.135
37.49.224.149
45.13.39.56
45.125.65.77
45.125.65.84
45.125.65.91
45.125.65.96
60.249.1.169
61.2.214.38
80.82.70.118
92.118.161.33
100.2.39.101
103.231.139.3
103.231.139.130
112.213.99.105
113.160.132.15
116.92.233.140
141.98.9.2
141.98.10.41
141.98.10.42
141.98.10.52
141.98.10.53
177.53.107.131
185.36.81.40
185.36.81.55
185.36.81.58
185.36.81.61
185.36.81.64
185.36.81.145
185.36.81.164
185.36.81.165
185.36.81.166
185.36.81.168
185.36.81.169
185.36.81.173
185.36.81.175
185.36.81.176
185.36.81.180
185.36.81.182
185.137.111.22
185.137.111.77
185.137.111.96
185.137.111.123
185.137.111.125
185.137.111.129
185.137.111.136
185.137.111.188
185.222.209.97
185.222.209.99
185.234.216.144
185.234.216.153
185.234.216.164
185.234.216.220
185.234.218.120
185.234.218.129
185.234.218.237
185.234.218.238
185.234.218.251
190.119.186.57
190.223.51.130
193.56.28.33
202.158.27.51

Also there is one IPv6 that I got:

2002:6402:2765::1

You see, there many /24 blocks full of such spammers. As said: this list
grows every day. It's a cat-vs-mouse game: for each server I block a new
one tries to attack me. You get into this as soon as you have a MX
record, your domain get's mentioned somewhere - and at least shodan
reveals you anyway. It's not just the e-mail-addresses that get's spamed
but also the mail-servers. And that's just my small domain not really
known and only exists since 2015. Imagine the mass of attacks popular
services like google has to block each day - thier block list is most
likely a few gigabyte in size.

Matt

Am 05.07.2019 um 08:42 schrieb Jason Tjankilisan:
Hiya Matt,

Sorry about the long time reply thank you for the detailed information.

About the generic mailet, I did read the GitHub version of it 
https://github.com/apache/james-project/blob/master/mailet/base/src/main/java/org/apache/mailet/base/GenericMailet.java
 and in the comment it did say the same thing about the Super.init(Config) so I 
apologize for my lack of attention. Thank you also for pointing out the SLF4J 
part, I will look more into that and for the java file, I already commented out 
the log() and the init(), destroy(), and getMailetInfo() function so only 
service(mail) left.

Also about the mailet naming thing, i ask for apology about that since my 
friend who set-up the file last time name it like that and I was afraid to 
change thinking it would corrupt the system since I still learning how the 
apache ANT compile works, so I dare not take any chances , but we sorted it out 
and changed the name.

Also sorry about the miscommunication, as I did write my class name like this 
in the mailetcontainer.xml (I was writing the class name as an example of a 
name, I should;ve the real class name, brain being derpy) :

164 <!-- Send remaining mails to the transport processor for either local or 
remote delivery --> Line
165        <mailet match="All" class="com.test.CustomMeiletTest"/>
166        <mailet match="All" class="ToProcessor">
167          <processor>transport</processor>
168             </mailet>

About the log doesn’t have the "wrapper stopped" I guess it doesn’t have that 
because I already make james run as a service , it will run continuously even though it 
failed and never “stopped”. So I did stop the service and run it using “james start” to 
see the error but turn out the problem was solved and my log finally showed up. (For the 
log4j.properties, I activate the debug one)

INFO  06:20:09,272 | com.test.CustomMeiletTest | Log via slf4j with INFO level 
!!! Add log4j.logger.com.test=INFO, CONS, FILE in the log4j.properties
DEBUG 06:20:09,272 | com.test.CustomMeiletTest | Log via slf4j with DEBUG level 
!!! Add log4j.logger.com.test=DEBUG, CONS, FILE in the log4j.properties
INFO  06:20:09,272 | com.test.CustomMeiletTest | This will show up at Logger if 
done correctly!

So I deeply thank you for the help and response and the patience to help me, 
there;s still a lot about james that I need to learn. I can finally have some 
progress to have mailet for signing DKIM and SPF.

P.S : I notice some strange log from my log like someone trying to login to my 
server multiple times, upon some quick search, its called AUTH LOGIN attack I 
think. Probably gonna look more into it first.

INFO  08:13:15,280 | 
org.apache.james.protocols.netty.BasicChannelUpstreamHandler | Connection 
established from 185.137.111.188
ERROR 08:13:15,348 | org.apache.james.protocols.api.handler.CommandHandler | 
AUTH method LOGIN failed from rut...@107.jp@185.137.111.188
INFO  08:13:15,364 | 
org.apache.james.protocols.netty.BasicChannelUpstreamHandler | Connection 
closed for 185.137.111.188

Sorry for any wrong word, and thank you for the help.

Sincerely, Jason

Sent from Mail for Windows 10

From: cryptearth
Sent: Thursday, July 4, 2019 4:44 PM
To: server-user@james.apache.org
Subject: Re: About Custom Mailet Configuration

Hey Jason,

have a look at the doc, I supply it on my server (sorry for no-frame
support - security header stuff set by apache config):
https://cryptearth.de/~cryptearth/doc/org/apache/mailet/base/GenericMailet.html

The doc says this:

init(MailetConfig): "When overriding this form of the method, call
super.init(config)."
You're using your own private field MailetConfig config - this cause
errors as you shadow the private field MailetConfig config in
super-class GenericMailet - wich then is "null" when used in other calls.
So, if you override init(MailetConfig) itself it is important that the
first line in it has to be "super.init(config)" to set the config field
in the super class. Also: don't add a field with type MailetConfig and
name "config" in your class as this shadow the super field. the better
way is you don't override init(MailetConfig) but only init().

Also: The doc says, that GenericMailet.log(String) and
GenericMailet.log(String, Throwable) are deprecated and you should use
SLF4J. So, this is how your sample should look like:

package com.test;
import javax.mail.MessagingException;
import org.apache.mailet.Mail;
import org.apache.mailet.base.GenericMailet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class MyMailet extends GenericMailet{
    private static final Logger logger =
LoggerFactory.getLogger(MyMailet.class);
    @Override
    public void service(Mail mail) throws MessagingException {
      // log("log via mailet logger with INFO level"); // no longer use
this line as log(String) is deprecated
      logger.info("Log via slf4j with INFO level !!! Add
log4j.logger.com.test=INFO, CONS, FILE in the log4j.properties");
      logger.debug("Log via slf4j with DEBUG level !!! Add
log4j.logger.com.test=DEBUG, CONS, FILE in the log4j.properties");
    }
}

That's all, fin. No private config field, no override init() - no log()
method - just the Logger instance and an info() and a debug().

About log levels: From the top of my head I think about four: debug,
info, warn, error. If you set your log-level to debug, you get anything,
if you set it only to info or warn you will get way less. I don't try to
say you can'T use both, but as the file is named ".properties" I can
almost asure you it uses java.util.Properties.load(), wich (IIRC) only
parses the first or the last line. So, it you have to lines with key
"log4j.logger.com.test" you will only get ONE of them (check the docs if
it's the first or the last one). So you can only use one of them.
For more info about log level and how to use them please ask google and
look up the doc and the site of slf4j and log4j.

Your config doesn't match with your class. You called your class:
com.test.CustomMeiletTest (btw: mailet comes from mail - and is therefor
written with an A, not with an E) but your config is given:
com.test.CustomMeiletTestClassName - this is wrong. If you give a
classname it has to exactly match. If you have a class called
"CustomMeiletTest" in the package "com.test" then that's
"com.test.CustomMeiletTest" - "com.test.CustomMeiletTestClassName" would
be a class called "CustomMeiletTestClassName". This is basic java you
have to obey. No way around it.

The error log you posted look still in-complete. it should end with a
line some like "wrapper stopped" or something like this. It still ends
the same where the one you posted already as mail - not helpful.



Last thing: I'm not the one to judge, but header says "X-MimeOLE:
Produced By Microsoft MimeOLE V6.1.7601.24158" (that's outlook express
on windows 7 SP1) and "jasonxc...@yahoo.com.INVALID" - so you obvious
somehow use a yahoo mail account with outlook express? IDC, I just
spotted it by looking for some hint about your attachements, it just
looks not right. Don't worry as long as it works (my james would simple
reject it as it would mark ".INVALID" as spam).

So long,

Matt

---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscr...@james.apache.org
For additional commands, e-mail: server-user-h...@james.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscr...@james.apache.org
For additional commands, e-mail: server-user-h...@james.apache.org

Reply via email to