[Helma-user] working with mail server and auto email processing
tobias.schaefer at orf.at
tobias.schaefer at orf.at
Sun Feb 18 13:13:06 CET 2007
Hi again
> just stumbled over dumpster (http://quintanasoft.com/dumbster/).
Thanks for the pointer. This really looks nice.
Actually, it's *exactly* what I was looking for.
However, in the meantime I came up with my own solution:
http://p3k.org/source/deviLib/trunk/Global/Simpiti.js
(You also need the Thread constructor available at [1].)
Using Simpiti in a Helma application, one can simply take the example at the Dumbster site and replace the line
SimpleSmtpServer server = SimpleSmtpServer.start();
with
var server = new Simpiti() .start();
and then remove the "Exception" type cast to make these few lines of code work in Helma:
var server = new Simpiti() .start();
try {
// Submits an email using javamail to the email server listening on port 25
// (method not shown here). Replace this with a call to your app logic.
sendMessage(25, "sender at here.com", "Test", "Test Body", "receiver at there.com");
} catch(e) {
e.printStackTrace();
fail("Unexpected exception: "+e);
}
server.stop();
(sendMessage() and fail() are custom methods which can be freely defined.)
A simple telnet session looks like this:
> telnet localhost 25
Trying ::1...
Connected to localhost.
Escape character is '^]'.
220 This is Simpiti
HELO 10.0.1.10
250 OK
MAIL FROM:<tobi at 10.0.1.10>
250 OK
RCPT TO:<helma at 10.0.1.18>
250 OK
DATA
354 Start mail data; end with <CRLF>.<CRLF>
Date: Sun, 18 Feb 2007 10:49:03 +0100 (CET)
From: tobi at 10.0.1.10
To: helma at 10.0.1.18
Message-ID: <8292956.01171792143654.JavaMail.root at 10.0.1.10>
Subject: Test with helma.Mail
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Hello, Simpiti!
.
250 OK
QUIT
221 Good bye
Connection closed by foreign host.
Of course, there still could be made a lot of improvements and security measures be taken. But the basics work and I was able to send mails to Simpiti from within Helma as well as from the command line. (Unfortunately, using Apple Mail failed but I assume this is due to some configuration issue in OS X I am currently not aware of.)
It should be simple to extend Simpiti to one's special needs.
Although using Dumbster could have been much easier, the whole task wasn't that difficult, actually.
And coding a simple SMTP server myself established some really new and interesting knowledge about the simple mail transport protocol and Java threads.
Ciao,
tobi
--
[1] http://p3k.org/source/deviLib/trunk/Global/Thread.js
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/ms-tnef
Size: 4276 bytes
Desc: not available
Url : http://helma.org/pipermail/helma-user/attachments/20070218/f2f8be8e/attachment.bin
More information about the Helma-user
mailing list