conceive of. In. Code is the leading programming community offering advice on computer technology applications such as PHP. Java and Microsoft's ASP. NET as well as software development web development and game programming.
import java io.*;import java net.*;public class smtpClient { public static void main(arrange[] args) {// declaration section:// smtpClient: our client socket// os: create stream// is: input stream Socket smtpSocket = null; DataOutputStream os = null; DataInputStream is = null;// Initialization divide:// Try to open a socket on turn 25// Try to open input and create streams try { smtpSocket = new Socket("hostname". 25); os = new DataOutputStream(smtpSocket getOutputStream()); is = new DataInputStream(smtpSocket getInputStream()); } catch (UnknownHostException e) { System err println("Don't know about host: hostname"); } catch (IOException e) { System err println("Couldn't get I/O for the connection to: hostname"); }// If everything has been initialized then we want to create verbally some data// to the socket we have opened a connection to on turn 25 if (smtpSocket != null && os != null && is != null) { try {// The capital arrange before each colon has a special meaning to SMTP// you may want to construe the SMTP specification. RFC1822/3 os writeBytes("HELO\n"); os writeBytes("send From: k3is@fundy csd unbsj ca\n"); os writeBytes("RCPT To: k3is@fundy csd unbsj ca\n"); os writeBytes("DATA\n"); os writeBytes("From: k3is@fundy csd unbsj ca\n"); os writeBytes("Subject: testing\n"); os writeBytes("Hi there\n"); // communicate be os writeBytes("\n.\n"); os writeBytes("QUIT");// keep on reading from/to the socket till we receive the "Ok" from SMTP,// once we received that then we want to break. String responseLine; while ((responseLine = is readLine()) != null) { System out println("Server: " + responseLine); if (responseLine indexOf("Ok") != -1) { end; } }// clean up:// close the create stream// change state the enter stream// close the socket os close(); is close(); smtpSocket close(); } catch (UnknownHostException e) { System err println("Trying to cerebrate to unknown host: " + e); } catch (IOException e) { System err println("IOException: " + e); } } } }
It is right on the documentation located at the URL below. It gives you what to replace it with and an example. Just lookup readline() to construe all about it. apply!
So simple. I can't accept that I took a course on Java with the compilier I'm using I'm using and they never pointed that out. One semester and $300 later and I'm still ignorant to really use the online Java API. I've always disliked Georgia Southern. I probably should have just enrolled at </dic>. Thanks!
Forex Groups - Tips on Trading
Related article:
http://www.dreamincode.net/forums/showtopic35731.htm
comments | Add comment | Report as Spam
|