|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi.
I am using Java to send mails using SMTP. I generate an aplication in Java, and this work so good in my computer, but, when I save the aplication in the server of my Internet service provider, the plaication do not work. Never send any error or warning message, just do not send the mail. Please, tell me what is wrong with my aplication. Thanks. The code of the aplication:////////////////// import java.io.PrintStream; import java.io.DataInputStream; import java.io.IOException; import java.io.OutputStream; import java.io.InputStream; import java.net.*; import java.lang.*; public class pruebaCorreoJava { static PrintStream ps = null; // envío de mensajes static DataInputStream dis = null; // recepción de mensajes public static void enviar(String str) throws IOException { ps.println(str); // enviar una cadena SMTP ps.flush(); // vaciar la cadena System.out.println("Java envió: " + str); } public static void recibe() throws IOException { String readstr = dis.readLine(); // obtener la respuesta SMTP System.out.println("respuesta SMTP: " + readstr); } public void main(String args[]) { String HELO = "HELO "; String MAIL_FROM = "MAIL FROM: yunuen@reporteroindustrial.com.mx"; String RCPT_TO = "RCPT TO: grusein@yahoo.com"; String DATA = "DATA"; // inicio del message String ASUNTO = "Subject: Respuesta a conflicto de Java!n"; // Nota: "n.n" indica el final el mensaje String MENSAJE = "Esta prueba es para mandar correos a cualquier usuario, pero debe ser ejecutado desde un HTML!n.n"; Socket smtp = null; // socket de SMTP try { // Nota: 25 es el número de puerto SMTP por omisión smtp = new Socket("mails.nettimes.com.mx",25); OutputStream os = smtp.getOutputStream(); ps = new PrintStream(os); InputStream is = smtp.getInputStream(); dis = new DataInputStream(is); } catch (IOException e) { System.out.println("Error al conectar: " + e); } try { // enviar el HELO String loc = InetAddress.getLocalHost().getHostName(); enviar(HELO + loc); recibe(); // obtener la respuesta SMTP enviar(MAIL_FROM); // enviar el remitente recibe(); // obtener la respuesta SMTP enviar(RCPT_TO); // enviar el receptor recibe(); // obtener la respuesta SMTP enviar(DATA); // enviar el inicio de mensaje recibe(); // obtener la respuesta SMTP enviar(ASUNTO); // enviar el asunto recibe(); // obtener la respuesta SMTP enviar(MENSAJE); // enviar el mensaje body recibe(); // obtener la respuesta SMTP smtp.close(); // cerrar la conexión } catch (IOException e) { System.out.println("Error al enviar:" + e); } System.out.println("Correo enviado!"); } } [This message has been edited by grusein (edited September 09, 2000).] |
|
#2
|
|||
|
|||
|
First off: any error message that you System.out.println() will go into the server logs of your ISP, and so you will not see it (unless you have access to those logs, ofcourse).
Second I would like to know how do you call your application once it's uploaded to your ISP? Servlet, applet, application? Are you sure they have Java support at all? Code looks good, and it works on your machine, so should be some other problem... Please supply some more info if you can. Ton |
![]() |
| Viewing: Dev Shed Forums > Web Design > HTML Programming > Problem to use SMTP |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|