Solved

Email from Java Applet

Posted on 1998-03-23
3
179 Views
Last Modified: 2010-04-16
Is it possible to send email directly from a java applet? Or does this require a CGI script? Using a CGI script is undesirable as it means the method would have to change for every different server, based on a CGI script the uses the POST and emails the result.

Is there a mechanism for getting data from an Applet to an email address without being dependent on the Server side (in many cases I can not run customized application at the server!)
0
Comment
Question by:sdj
  • 2
3 Comments
 
LVL 6

Expert Comment

by:gadio
ID: 1233723
 It is possible through the use of the mail server on the server side. You don't need to use any special application as the mail server is usually installed on any UNIX machine, and comes up at boot time. By default it works with SMTP (simple mail transfer protocol) and listens on port 25.
Have a look at:
http://lgr.se/mailclient.htm
You can get a source code for sending and reading mail there.
0
 

Author Comment

by:sdj
ID: 1233724
This sample does not give any source code for an applet to send email. I actualy want to write the code rather than use somebody else pre-written java.

Is this sample actually valid from an applet as well as an application?
0
 
LVL 6

Accepted Solution

by:
gadio earned 50 total points
ID: 1233725
 Well sdj, I can give you source code if you want. It seems though that you want to write it yourself. Here's what you should do. You can try and read about the SMTP protocol. You can also telnet to your ISP server (or to another machine with a mail server) to port 25, and play along with the protocol. You would see that its very simple and with basic java networking knowledge you can write this code. In general I'll describe a simple send procedure in java:
o Initiate connection to the server (the machine where that applet came from) through
   socket to port 25.
o send "helo IP" command, where IP = the ISP IP, or name.
o check success (As I remember it means that you receive a line beginning with "250 ").
o send "mail from: user" where user = your email address.
o check success.
o send "rcpt to: name" where name = the destination address.
o check success.
o send "data" command
o send "Subject: xxx", xxx = whatever.
o send your text.
o send a line with only a single dot.
o check success.

And that's it! its very simple. You should check that before writing (use telnet) as I didn't. You should also improve the error handling etc.

Hope that helps.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
strDist challenge 35 84
topping1 challenge 7 51
base64 decode encode 12 96
What is the latest versions eclipse neon 2 120
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now