Ver Mensaje Individual
  #4 (permalink)  
Antiguo 25/01/2006, 09:07
Ace_ventura
 
Fecha de Ingreso: octubre-2005
Mensajes: 188
Antigüedad: 18 años, 6 meses
Puntos: 0
Mira este codigo a ver
Código PHP:
import java.util.Properties;
import javax.mail.*;
import javax.mail.internet.*;

public class 
MailExample1 {
public static 
void main (String args[]) throws Exception {
String host args[0];
String from args[1];
String to args[2];

// Get system properties
Properties props System.getProperties();

// Setup mail server
props.put("mail.smtp.host"host);
Authenticator auth = new MyAuthenticator();

// Get session 
Session session Session.getDefaultInstance(propsauth);

// Define message
MimeMessage message = new MimeMessage(session);

// Set the from address
message.setFrom(new InternetAddress(from));

// Set the to address
message.addRecipient(Message.RecipientType.TO
new 
InternetAddress(to));

// Set the subject
message.setSubject("Hello");

// Set the content
message.setText("Welcome");

// Send message
Transport.send(message);
}


static class 
MyAuthenticator extends Authenticator {
PasswordAuthentication l = new PasswordAuthentication("username""password"); 
protected 
PasswordAuthentication getPasswordAuthentication() {
return 
l;
}
}

Basicamente es el mismo ke puso NanoWare salvo por una linea en la ultima clase, a mi me funciona.