HTML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignHTML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old September 9th, 2000, 02:24 PM
grusein grusein is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2000
Location: Puerto Vallarta, Jalisco, Mexico
Posts: 3 grusein User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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).]

Reply With Quote
  #2  
Old October 2nd, 2000, 04:40 AM
tvanbart tvanbart is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2000
Posts: 35 tvanbart User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
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

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignHTML Programming > Problem to use SMTP


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway