The first version of the receiver was done using JavaMail. I did experiment some troubles with the "Quoted-Transfer-Encoding", sometimes the content was broken.
Using the current version of the GAE/J (1.3.0) the emails content received from Gmail or from Thunderbird is correct and the channel seems to be reliable.
Mime4J
An alternative for receiving email is the James Mime4J project.The library doesn't have dependencies and works on the GAE/J. It is quite simple to use; instead of:
import java.io.InputStream;
import java.util.Properties;
import javax.mail.Session;
import javax.mail.internet.MimeMessage;
...
InputStream input = request.getInputStream(); // ServletRequest
Properties props = new Properties();
Session session = Session.getDefaultInstance(props, null);
MimeMessage message = new MimeMessage(session, input); // MessagingException
...
you have to use:import java.io.InputStream;
import org.apache.james.mime4j.message.Message;
import org.apache.james.mime4j.message.MessageBuilder;
import org.apache.james.mime4j.parser.ContentHandler;
import org.apache.james.mime4j.parser.MimeStreamParser;
import org.apache.james.mime4j.storage.MemoryStorageProvider;
...
InputStream input = request.getInputStream(); // ServletRequest
Message message = new Message();
ContentHandler handler = new MessageBuilder(message, new MemoryStorageProvider());
MimeStreamParser parser = new MimeStreamParser();
parser.setContentHandler(handler);
parser.parse(input); // MimeException
...
The result seems to be better than the one which uses JavaMail. The mails received from the MS Outlook are readable. It remains a small problem with the encoding which I will investigate later this year.Incoming Mail Syntax
The syntax of the incoming mail was changed:description line 1 line 2 ... line n end link http://myserver/mylink end categories category 1 category 2 ... category n endEach command block starts with a keyword and ends with end
Informations
The email address of the Mime4J service is mime4j@example-rest.appspotmail.com, the JavaMail based receiver still works with rss2@example-rest.appspotmail.comThe application URL is example-rest.appspot.com.
Nice work!
ReplyDeleteHave you got it bug free now?
Tanks for the comment. I didn't really check this interface with more recent versions of the GAE. At that time I was interested in it because my phone did send SMS and mails only. Now, with a smartphone, I don't really need it anymore.
ReplyDelete