/ * use the program: java clienteSMTP
Free use, explicitly stating: "extracted from www.vgvvictor.tk" * /
import java.util .*;
import java.io. *;
import java.net .*;
clienteSMTP {
class static Scanner keyboard = new Scanner (System.in);
public static void main (String args []) throws UnknownHostException, IOException {
/ / initialization
servidor_SMTP
String = args [0];
mi_socket = new Socket Socket (servidor_SMTP, 25), / / \u200b\u200bI think a connected socket
Scanner input = new Scanner (mi_socket.getInputStream ());
PrintWriter output = new PrintWriter (mi_socket.getOutputStream ());
myhost = InetAddress.getLocalHost
InetAddress ();
mi_host_string = mi_host.getHostName String ();
boolean continue;
/ / user data supplied then
String to = "";
String from = "";
String subject;
/ / start the party
continue = continue (input);
if (continue) {
salida.print ("HELO" + mi_host_string + "\\ r \\ n");
salida.flush ();
continue = continue (input);
} if (continue)
{System.out.println ("Mail Source:");
teclado.nextLine from = ();
salida.print ("MAIL From: <" + from + "> \\ r \\ n ");
salida.flush ();
continue = continue (input);
} if (continue)
{System.out.println (" mail destination ");
teclado.nextLine to = ( )
salida.print ("RCPT To: <" + to + "> \\ r \\ n");
salida.flush ();
continue = continue (input);
} if (continue) {
salida.print ("DATA \\ r \\ n ");
salida.flush ();
continue = continue (input);
} if (continue)
{System.out.println ("Subject:");
teclado.nextLine subject = ();
salida.print ( "From:" + from + "\\ r \\ nt:" + to + "\\ r \\ nSubject:" + subject + "\\ r \\ n");
procesador_de_texto (output);
/ / salida.print ("Hello world \\ r \\ n \\ r \\ n "); TEST
salida.flush ();
continue = continue (input);
} if (continue) {
salida.print (" QUIT ");
output. flush ();}
} / * as the teclado.hasNext () does not work properly if the standard input is not redirected to a file, use a word
assistant for sending * / static void
procesador_de_texto (PrintWriter salt) {System.out
. println ("Enter your message: \\ n (to make the shipment, type @ SEND on a new line)");
linea_actual = teclado.nextLine String ();
while (! linea_actual.equals ("@ SEND" )) {
/ / System.out.println (
"##"); linea_actual + char A = linea_actual.charAt (0);
if (A =='.'){
linea_actual = '. " + Linea_actual;
} sal.print (linea_actual + "\\ r \\ n");
teclado.nextLine linea_actual = ();}
sal.print (". \\ R \\ n");}
we
static boolean (Scanner notif) {int code = entr.nextInt
();
entr.nextLine String explanation = ();
primera_cifra int = codigo/100;
/ / System.out.println (code + explanation + "" + primera_cifra) ;
if ((primera_cifra == 2) ABORTED! ");
return false;
}}}
0 comments:
Post a Comment