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 Shal Jain <sh...@intertechsys.com> on 2002/10/16 20:44:08 UTC

mail bounce question

James ver 2.0a2 running under Win2K

Within a custom mailet I have the following code that handles certain error conditions:

void handleError(Mail mail,String errMsg)
{
    try{
      MailetContext context = this.getMailetContext();
      context.bounce(mail,errMsg,new MailAddress(deliveryFailureAddr));
      mail.setState(Mail.GHOST);
    }
    catch(Exception nex)
    {
      log(nex.getMessage());
      mail.setState(Mail.ERROR);
    }
}


The bounce does work but the bounced mail appears in the following form

<< errMsg >>

_____________________________

<< body of the original message >>



If I want to bounce the initially received email back as an attachment - what's the preferred approach ?

Do I need to use context.SendMessage() and try to compose the MimeMessage myself or can I redirect to the
default bounce processor where all the work is already being done.

TIA

-shal





RE: mail bounce question

Posted by Danny Angus <da...@apache.org>.
> How can I supply the notice w/out configuring it in config.xml

you can write the error_message with mail.setErrorMessage("blah");

> Is there a better approach for what I'm trying to do.

in your custom processor use Redirect, rather than "forward" or "notify", redirect has options for various types of attachment and inline content, including attaching the original as a mail message.
http://jakarta.apache.org/james/javadocs/org/apache/james/transport/mailets/Redirect.html

d.

PS failed delivery bounces are coded in to James, you might not be able to get at them to use.



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: mail bounce question

Posted by Shal Jain <sh...@intertechsys.com>.
Oops - sent the query too soon.
I think I found most of the answer

void handleError(Mail mail,void errMsg)
{
    mail.setState("MyCustomBounce");
}

... somewhere in spoolmanager...

<processor name="MyCustomBounce">
    <mailet match="All" mailet="NotifySender">
    </mailet>
</processor>

Howerver,
I'd still like to include a specific error message and then include the
original email as an attachment in the bounce
Per javadocs
Sample configuration: nobounce@localhost true Notice attached to the message
(optional)

How can I supply the notice w/out configuring it in config.xml

If I use context.setAttribute("MY_ERR_MSG",errMsg) and extend NotifySender
mailet I think I could get what I need (haven't looked at the code of
NotifySender yet).

Is there a better approach for what I'm trying to do.


-shal




----- Original Message -----
From: "Shal Jain" <sh...@intertechsys.com>
To: "James Users List" <ja...@jakarta.apache.org>
Sent: Wednesday, October 16, 2002 1:44 PM
Subject: mail bounce question


James ver 2.0a2 running under Win2K

Within a custom mailet I have the following code that handles certain error
conditions:

void handleError(Mail mail,String errMsg)
{
    try{
      MailetContext context = this.getMailetContext();
      context.bounce(mail,errMsg,new MailAddress(deliveryFailureAddr));
      mail.setState(Mail.GHOST);
    }
    catch(Exception nex)
    {
      log(nex.getMessage());
      mail.setState(Mail.ERROR);
    }
}


The bounce does work but the bounced mail appears in the following form

<< errMsg >>

_____________________________

<< body of the original message >>



If I want to bounce the initially received email back as an attachment -
what's the preferred approach ?

Do I need to use context.SendMessage() and try to compose the MimeMessage
myself or can I redirect to the
default bounce processor where all the work is already being done.

TIA

-shal







--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: mail bounce question

Posted by Shal Jain <sh...@intertechsys.com>.
I just ran a test and got back a bounce as described in my email
One thing that I did forgot to include in the code was the following line

context.storeMail(mail.getSender(),new MailAddress(unfiledEmailAddr),
mail.getMessage());

which is immediately followed by
context.bounce(mail,errMsg,new MailAddress(deliveryFailureAddr));


Could the fact that I am storing the message against a known location
somehow alter the bounce behaviour
The store was strictly done for some debugging purposes and got left in
there.
I havent' tried the mailet with the store method commented out.

I have received bounced emails w/ the original packaged as an attachment for
cases where I'm originating the
email and James is unable to deliver to an external domain.  I'd like to get
the same bounce behaviour
when James is receiving.

-shal


----- Original Message -----
From: "Noel J. Bergman" <no...@devtech.com>
To: "James Users List" <ja...@jakarta.apache.org>
Sent: Wednesday, October 16, 2002 2:19 PM
Subject: RE: mail bounce question


> Shal,
>
> As I read James.bounce(Mail, String, MailAddress), it does send the
original
> as an attachment, and I've received bounces packaged just that way.
>
> --- Noel
>
> -----Original Message-----
> From: Shal Jain [mailto:shal_jain@intertechsys.com]
> Sent: Wednesday, October 16, 2002 14:44
> To: James Users List
> Subject: mail bounce question
>
>
> James ver 2.0a2 running under Win2K
>
> Within a custom mailet I have the following code that handles certain
error
> conditions:
>
> void handleError(Mail mail,String errMsg)
> {
>     try{
>       MailetContext context = this.getMailetContext();
>       context.bounce(mail,errMsg,new MailAddress(deliveryFailureAddr));
>       mail.setState(Mail.GHOST);
>     }
>     catch(Exception nex)
>     {
>       log(nex.getMessage());
>       mail.setState(Mail.ERROR);
>     }
> }
>
>
> The bounce does work but the bounced mail appears in the following form
>
> << errMsg >>
>
> _____________________________
>
> << body of the original message >>
>
>
>
> If I want to bounce the initially received email back as an attachment -
> what's the preferred approach ?
>
> Do I need to use context.SendMessage() and try to compose the MimeMessage
> myself or can I redirect to the
> default bounce processor where all the work is already being done.
>
> TIA
>
> -shal
>
>
>
>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: mail bounce question

Posted by "Noel J. Bergman" <no...@devtech.com>.
Shal,

As I read James.bounce(Mail, String, MailAddress), it does send the original
as an attachment, and I've received bounces packaged just that way.

	--- Noel

-----Original Message-----
From: Shal Jain [mailto:shal_jain@intertechsys.com]
Sent: Wednesday, October 16, 2002 14:44
To: James Users List
Subject: mail bounce question


James ver 2.0a2 running under Win2K

Within a custom mailet I have the following code that handles certain error
conditions:

void handleError(Mail mail,String errMsg)
{
    try{
      MailetContext context = this.getMailetContext();
      context.bounce(mail,errMsg,new MailAddress(deliveryFailureAddr));
      mail.setState(Mail.GHOST);
    }
    catch(Exception nex)
    {
      log(nex.getMessage());
      mail.setState(Mail.ERROR);
    }
}


The bounce does work but the bounced mail appears in the following form

<< errMsg >>

_____________________________

<< body of the original message >>



If I want to bounce the initially received email back as an attachment -
what's the preferred approach ?

Do I need to use context.SendMessage() and try to compose the MimeMessage
myself or can I redirect to the
default bounce processor where all the work is already being done.

TIA

-shal






--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>