You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-user@james.apache.org by Jan Drake <ja...@gmail.com> on 2013/10/09 23:41:39 UTC
Apache James 2.3 Protocol Handler
Hello,
We have an urgent situation where we need to be able to reject inbound
messages at the smtp layer. Essentially, we need to take the whole message
after the .<crlf><crlf> in the smtp protocol, evaluate it, and then return
in certain conditions and appropriate SMTP error message to notify the
sender the message was not accepted (and why).
Seems like james-smpthandler.xml would enable us to do this but can't find
ANY real examples of handlers and how to configure them in properly for this
scenario.
Any assistance is welcome and GREATLY appreciated.
Jan.s.drake@gmail.com
Jan
Re: Apache James 2.3 Protocol Handler
Posted by Eric Charles <er...@apache.org>.
Thx. Anyone willing to contribute a patch on trunk?
On 15/10/13 10:11, Hamster wrote:
> Hi guys,
>
> Took me a while... ;-)
>
> In /apps/james/conf/james-smtphandlerchain.xml
> http://fisheye.primekey.se/browse/SignServer/trunk/signserver/extapps/james/apps/james/conf/james-smtphandlerchain.xml?r=93
>
> just before SendMailHandler we added our own handlers, for example:
>
> <handler class="x.y.z.AbortProcessingMessageHandler"></handler>
>
> In config.xml make sure that &smtphandlerchainConfig is NOT commented out.
>
>
> Out very simple implementation:
>
> public class AbortProcessingMessageHandler implements MessageHandler {
> ....
> @Override
> public void onMessage(SMTPSession session) {
> if (blacklistService.isBlacklisted(session)) {
> String responseString = "250 " +
> DSNStatus.getStatus(DSNStatus.SUCCESS, DSNStatus.CONTENT_OTHER) + "
> Message received";
> session.writeResponse(responseString);
>
> session.abortMessage();
> }
> }
> .....
> }
>
>
> Hope it is enough to let you move on.
>
>
> One more example:
>
> @Override
> public void onMessage(SMTPSession session) {
> if (session == null || session.getMail() == null ||
> session.getMail().getSender() == null ||
> session.getMail().getRecipients() == null
> || session.getMail().getRecipients().isEmpty()) {
> return;
> }
>
> if (config.getEmailHost().equals(session.getMail().getSender().getHost())) {
> return;
> }
>
> final Collection<MailAddress> recipients =
> session.getMail().getRecipients();
> for (MailAddress mailAddress : recipients) {
> if (!config.getEmailHost().equals(mailAddress.getHost())) {
> statisticsService.incrementEmailsAcceptedForRemoteDelivery();
> }
> }
> }
>
>
> Cheers,
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org
Re: Apache James 2.3 Protocol Handler
Posted by Hamster <ha...@gmail.com>.
Hi guys,
Took me a while... ;-)
In /apps/james/conf/james-smtphandlerchain.xml
http://fisheye.primekey.se/browse/SignServer/trunk/signserver/extapps/james/apps/james/conf/james-smtphandlerchain.xml?r=93
just before SendMailHandler we added our own handlers, for example:
<handler class="x.y.z.AbortProcessingMessageHandler"></handler>
In config.xml make sure that &smtphandlerchainConfig is NOT commented out.
Out very simple implementation:
public class AbortProcessingMessageHandler implements MessageHandler {
....
@Override
public void onMessage(SMTPSession session) {
if (blacklistService.isBlacklisted(session)) {
String responseString = "250 " +
DSNStatus.getStatus(DSNStatus.SUCCESS, DSNStatus.CONTENT_OTHER) + "
Message received";
session.writeResponse(responseString);
session.abortMessage();
}
}
.....
}
Hope it is enough to let you move on.
One more example:
@Override
public void onMessage(SMTPSession session) {
if (session == null || session.getMail() == null ||
session.getMail().getSender() == null ||
session.getMail().getRecipients() == null
|| session.getMail().getRecipients().isEmpty()) {
return;
}
if (config.getEmailHost().equals(session.getMail().getSender().getHost())) {
return;
}
final Collection<MailAddress> recipients =
session.getMail().getRecipients();
for (MailAddress mailAddress : recipients) {
if (!config.getEmailHost().equals(mailAddress.getHost())) {
statisticsService.incrementEmailsAcceptedForRemoteDelivery();
}
}
}
Cheers,
--
http://music-codex.com/
http://hamsterready.blogspot.com/
http://full-plate.blogspot.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org
Re: Apache James 2.3 Protocol Handler
Posted by Fernando Cassia <fc...@gmail.com>.
On Mon, Oct 14, 2013 at 8:21 AM, Jan Drake <ja...@gmail.com> wrote:
> Yes, please. Appreciate the sharing! :)
Can this be documented/added to next release/docs?? Please? ::
TIA
FC
--
During times of Universal Deceit, telling the truth becomes a revolutionary
act
Durante épocas de Engaño Universal, decir la verdad se convierte en un Acto
Revolucionario
- George Orwell
Re: Apache James 2.3 Protocol Handler
Posted by Jan Drake <ja...@gmail.com>.
Yes, please. Appreciate the sharing! :)
On 10/10/13 5:09 PM, "Hamster" <ha...@gmail.com> wrote:
>Hi Jan,
>
>We did something like that. Our use case was for throttling purposes (if
>too many emails per sec from address x then reply with different smtp
>code). Is this what you need(or similar)?
>
>Will share tomorrow when next to my laptop.
>
>Cheers
>On Oct 9, 2013 11:42 PM, "Jan Drake" <ja...@gmail.com> wrote:
>
>> Hello,
>>
>> We have an urgent situation where we need to be able to reject inbound
>> messages at the smtp layer. Essentially, we need to take the whole
>>message
>> after the .<crlf><crlf> in the smtp protocol, evaluate it, and then
>>return
>> in certain conditions and appropriate SMTP error message to notify the
>> sender the message was not accepted (and why).
>>
>> Seems like james-smpthandler.xml would enable us to do this but can't
>>find
>> ANY real examples of handlers and how to configure them in properly for
>> this
>> scenario.
>>
>> Any assistance is welcome and GREATLY appreciated.
>>
>>
>> Jan.s.drake@gmail.com
>>
>> Jan
>>
>>
>>
>>
---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org
Re: Apache James 2.3 Protocol Handler
Posted by Hamster <ha...@gmail.com>.
Hi Jan,
We did something like that. Our use case was for throttling purposes (if
too many emails per sec from address x then reply with different smtp
code). Is this what you need(or similar)?
Will share tomorrow when next to my laptop.
Cheers
On Oct 9, 2013 11:42 PM, "Jan Drake" <ja...@gmail.com> wrote:
> Hello,
>
> We have an urgent situation where we need to be able to reject inbound
> messages at the smtp layer. Essentially, we need to take the whole message
> after the .<crlf><crlf> in the smtp protocol, evaluate it, and then return
> in certain conditions and appropriate SMTP error message to notify the
> sender the message was not accepted (and why).
>
> Seems like james-smpthandler.xml would enable us to do this but can't find
> ANY real examples of handlers and how to configure them in properly for
> this
> scenario.
>
> Any assistance is welcome and GREATLY appreciated.
>
>
> Jan.s.drake@gmail.com
>
> Jan
>
>
>
>
Apache James 2.3 Protocol Handler
Posted by Jan Drake <ja...@gmail.com>.
Retrying to list
From: Jan Drake <ja...@gmail.com>
Date: Wednesday, October 9, 2013 2:41 PM
To: <se...@james.apache.org>
Subject: Apache James 2.3 Protocol Handler
Hello,
We have an urgent situation where we need to be able to reject inbound
messages at the smtp layer. Essentially, we need to take the whole message
after the .<crlf><crlf> in the smtp protocol, evaluate it, and then return
in certain conditions and appropriate SMTP error message to notify the
sender the message was not accepted (and why).
Seems like james-smpthandler.xml would enable us to do this but can't find
ANY real examples of handlers and how to configure them in properly for this
scenario.
Any assistance is welcome and GREATLY appreciated.
Jan.s.drake@gmail.com
Jan