Bosco,

There is a getMailetContext.sendMail() method that accepts a sender,
recipient, and mail message.  Change the sender to the person that you
want the return path to be and it should work.

context.sendMail(sender, forwardto, msg);

Cheers,
Hut

-----Original Message-----
From: Bosco So [mailto:[EMAIL PROTECTED] 
Sent: Monday, September 08, 2003 1:23 PM
To: James Users List
Subject: setting Return-Path in mailet


I'm generating email messages from within a mailet. How do I create a 
Return-Path header that's different from the From header? When I create 
email messages outside James using the JavaMail API, the following code 
gives me a Return-Path header that's different from the From header. 
However, the same code in James results in email messages where the 
Return-Path is taken from the From header (and the values I set in 
msg.setEnvelopeFrom is ignored).

            Properties props = new Properties();
            Session msess = Session.getDefaultInstance(props, null);
            SMTPMessage msg = new SMTPMessage(msess);

            String bounceAddress =
"[EMAIL PROTECTED]";
            msg.setEnvelopeFrom(bounceAddress);
            try {
                msg.setFrom(new
InternetAddress("[EMAIL PROTECTED]",
                                                "From Handler"));
                msg.setReplyTo(new InternetAddress[] {
                    new
InternetAddress("[EMAIL PROTECTED]",
                                        "Reply Handler")});
            }
            catch (java.io.UnsupportedEncodingException cannotHappen) {}

            msg.setRecipient(Message.RecipientType.TO,
"[EMAIL PROTECTED]");
            msg.setSubject("test subject");
            msg.setContent("test message", "text/plain");


Am using James 2.2.0a9 on RedHat Linux 8 with Sun JDK1.4.2.

 
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
BOSCO SO                                   www.groundspring.org

Senior Software Engineer, Groundspring.org.  Growing nonprofits with
Internet tools and training.

DonateNow:  Accept credit card donations through your website
 EmailNow:  Send eNewsletters and communicate with supporters
    ebase:  Manage your stakeholder relationships

Groundspring.org, P.O. Box 29256, San Francisco, CA 94129-0256 . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to