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