Solved

Email from Java Applet

Posted on 1998-03-23
3
193 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
null output 3 59
What browser will run Java? 7 182
Coding for the first time 9 103
Bitwise and to sum elements 2 54
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

752 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