Solved

Email from Java Applet

Posted on 1998-03-23
3
198 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
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.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

636 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