Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Applets
Expertise: Beginner
Jul 23, 1997

Writing applet to send info from forms to email address

Question:
I am wondering if I can write an applet that will send information from a number of forms to my email address without all the %$= etc. and without using CGI scripts (my server doesn't allow CGI scripts).

Answer:
If the SMTP port (25) on your web server hasn't been disabled by the system administrator, you can open a socket to it and mimic the SMTP protocol. Let's say your host is www.sun.com:

Socket s = new Socket("www.sun.com", 25);
   PrintStream out = newPrintStream(s.getOutputStream());
Then send the string:
 HELO xxx
   MAIL FROM: yyy
   RCPT TO: baker@www.sun.com
   DATA
   
. QUIT
Note the misspelling of "HELO". I've done this on purpose to make the point that the xxx and yyy can be anything; SMTP doesn't check. Don't miss the "." on the second-to-last line.
DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date