james-server-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Norman Maurer <nor...@apache.org>
Subject Re: Cannot access text/plain content of SMTP message in simple mailet
Date Tue, 11 Jan 2011 09:12:50 GMT
Hi there,

your smtp transaction is wrong.. Try this:

helo private.com
mail from: <xyz@private.com>
rcpt to: <xyz@private.com>
data
Subject: test

test
.
quit


Let me know if it work.. As noted in the RFC headers and body need to
be seperated by CRLFCRLF.

Bye,
Norman


2011/1/11 agks mehx <agksmehx@gmail.com>:
> Hi,
>
> I cannot access the text content of a simple text/plain email sent to the
> James SMTP server.  This is my first mailet and I got the same problem with
> M2 and a recent M3-snapshot.
>
> The following is the most simplified version of the source.  The following
> code returns an *empty string*: String content =
> (String)mime_message.getContent();
>
> After running the server, I telnet to port 25 and copy paste the following
> commands:
>
> helo private.com
> mail from: <xyz@private.com>
> rcpt to: <xyz@private.com>
> data
> test
> .
> quit
>
> Source of mailet follows:
>
> package com.private.main.mailet;
>
> import java.io.IOException;
>
> import javax.mail.MessagingException;
> import javax.mail.internet.MimeMessage;
>
> import org.apache.mailet.Mail;
> import org.apache.mailet.Mailet;
> import org.apache.mailet.MailetConfig;
>
> public class Test implements Mailet {
>
>  protected MailetConfig mailet_config;
>
>  public void init (MailetConfig mailet_config) {
>    this.mailet_config = mailet_config;
>  }
>
>  public void destroy () {
>  }
>
>  public MailetConfig getMailetConfig () {
>    return this.mailet_config;
>  }
>
>  public String getMailetInfo () {
>    return "Test Mailet";
>  }
>
>  public void service (Mail mail) throws MessagingException {
>    try {
>      MimeMessage mime_message = mail.getMessage();
>      mail.setState(Mail.GHOST);
>      System.out.println("content_type: " + mime_message.getContentType());
>      if (mime_message.isMimeType("text/plain")) {
>        String content = (String)mime_message.getContent();
>        System.out.println(content);
>      }
>    } catch (IOException e) {
>      System.err.println("got an IOException:");
>      e.printStackTrace();
>    }
>  }
>
> }
>
> Thanks for any help!
>

---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


Mime
View raw message