Warnning! the applets can run in one of the following ways:

  1. As a standalone applet. It needs that the web server and the smtp server are the same computer (due to Java security constrains).
  2. Together with a servlet. In this case the server is the one that sends the e-mail (this would be a client/server architecture). The smtp server can be other than the web server.

The product comes with the applets and the source code for both cases (including servlet).

Running the applets

If you want to test the standalone applets you must provide the following parameters for the applet:

  1. MY_MAIL (the e-mail address you want to send from)

  2. MY_COMPUTER (your computer name or address)

If you want to test the applets and the servlet you must provide the following parameters for the applet:

  1. RMAIL_SERVLET (parameter of the applet). The address of the servlet. For example: "http://localhost:8080/servlet/RMailServlet"
  2. Configure the servlet with the following parameters

    for example, the file servlet.properties could be: RMailServer.initparams=SERVER=127.0.0.1,COMPUTER=127.0.0.1,USER=user@company.com,DEBUG=Y

 

Sample applet to send an email:

Java not supported

Sample applet to send this html page:

Java not supported

 


 

Programming with RMail

 

Receiving email  5 lines!

Sample source code to receive email:

pop.connect("pop.mycompany.com","user","pwd");  // Connect
for (int i=1;i<=pop.msgs;i++) {    // iterate on number of messages
   MailMsg m=pop.retrieveMsg(i);             // get message
   pop.deleteMsg(i);                    // delete message

   // do here whatever you like with the MailMsg object (variable m)
}
pop.disconnect();                       // disconnect

 

Sending an email and attachment 10 lines!

This is a sample source code to send an email:

m=new MailMsg();                                                // create email
m.from="user1@mycompany.com";                        // sender and receiver
m.addRecipient("user2@mycompany.com");
m.subject="test";
part=new MainMsgPart();                                    // add text part
part.setData("This is the text",MimeEncoder.QUOTED);
part.addPart(part);
m.addFile(new java.io.File("c:\\mydocument.doc"));  // add attachment
m.smtpServer="smtp.mycompany.com";
m.mail();                                                                // send mail

 

Sending alternative parts (Text and HTML)

This is a sample source code to send an email which contains two versions of the text (plain text and html):

m=new MailMsg();                                            // create email
m.from="user1@mycompany.com";                        // sender and receiver
m.addRecipient("user2@mycompany.com");
m.subject="test";


part=new MainMsgPart();                              // create alternative
part.ContentType="Multipart";
part.ContentSubType="Alternative";


textpart=new MainMsgPart();                                    // add text part to the alternative
textpart.setData("This is the text",MimeEncoder.QUOTED);
part.addPart(textpart);


htmlpart=new MainMsgPart();                                    // add html part to the alternative
htmlpart.ContentType="Text";
htmlpart.ContentSubType="Html";
htmlpart.setData("<html><body>This is the text</body></html>",MimeEncoder.QUOTED);
part.addPart(htmlpart);


m.addPart(part);
m.smtpServer="smtp.mycompany.com";
m.mail();                                                                      // send mail