Le 08/07/2020 à 14:40, David Leangen a écrit :
> Sorry, I do have one more question in response to your email…
>
> You wrote:
>
>> In my opinions we should document "How to write hooks with the
>> protocols/smtp library", "How to plug such hooks into a running James
>> server"
>>
>> Then "How to write commands for the protocols/smtp library" (and how to
>> plug them in James)
> This is starting to make better sense to me now. Thanks for your patience.
>
> Moving on… on this page:
>
>   —> https://james.apache.org/server/feature-smtp-hooks.html
>
>
>> The James SMTP Server Component allows to easy write your own code which 
>> will get executed in the SMTP-Transaction. Thats a bit different then using 
>> a Mailet a.k.a Mailet-API.
>>
>> To customize your SMTP Server, you have a few interfaces which helps you to 
>> "hook-in" a specific SMTP Command. That means your class which implements 
>> the given interface(s) will get called after the SMTP-Command was parsed and 
>> depending on your implementation it will handle it.
>>
>> As your code will get executed before the mail was even accepted. This can 
>> help you in many ways, most times its used for rejecting SPAM/Junk within 
>> the SMTP-Dialog. But it can be used for other things too.
>>
>> Its up to you and your use case.
>>
>> But be aware as your code needs to get executed during the SMTP-Transaction 
>> it should not take to long to execute. As it will need to fit in before the 
>> timeout was hit which can be different on every mail server. But as a 
>> general rule as long as your code can get executed within 30 seconds it 
>> should be fine.
>
> There is even a list of hooks on this page:
>
>   —> https://james.apache.org/server/dev-provided-smtp-hooks.html
>
>
> However… Can you provide more examples to help me better understand why I 
> should care about these hooks, and why I would want to consider using a hook 
> instead of a Mailet? Wouldn’t it be simpler just to have a single extension 
> mechanism? What is the value of having two different extension mechanisms?
That is a VERY nice question that needs to be clearly highlighted in the
documentation "given my use case, which extension mechanism should I use".

There's somehow an overlap between hooks and mailets but:

 - Mailet is *asynchronous*. SMTP clients will not be affected by
potentially long processing. Hooks are on the other hand synchronous,
the SMTP client needs to wait for them to happen.
 - Hooks are very cheap. The mail is not stored yet. This makes it
really useful to get rid of spam via IP filtering, MX hosts checks and
so on. Another use case would be DOS prevention.
 - Hook allow configuration of extra additional behaviors at the SMTP
layer like "Sender needs to be valid, etc...".

I believe however that this extension mechanism is less useful than
mailet / matchers.

Does it helps?
>
> Thanks!
>
> =David
>

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

Reply via email to