Ver Mensaje Individual
  #9 (permalink)  
Antiguo 26/01/2006, 21:24
blackwind
 
Fecha de Ingreso: noviembre-2003
Ubicación: Mexico
Mensajes: 1.081
Antigüedad: 22 años, 11 meses
Puntos: 7
excelente willie, muchas gracias.
Eso era lo que necesitaba y ya me quedo.

Por si a alguien le interesa, aqui les dejo el codigo
package com.radicalsoftware.rademailhosting;

Código PHP:
import javax.mail.*;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import java.util.Properties;

/***********************************************
/* JavaMail SSL + Authentication - Example Code
/************************************************/
public class Mailer
{

    public static 
void main(String[] args)
    {
        
Mailer obj = new Mailer();
        
String server = "smtp.gmail.com";
        
String userName = "[email protected]";
        
String password = "password";
        
String fromAddres = "perenganito";
        
String toAddres = "[email protected]";
        
String cc = "";
        
String bcc = "";
        
boolean htmlFormat = false;
        
String subject = "tema";
        
String body = "prueba";
        
        
obj.sendMail(server, userName, password, fromAddres, toAddres, cc, bcc,
                     
htmlFormat, subject, body);
        
    }

    public 
void sendMail(String server, String userName, String password, String fromAddress, String toAddress, String cc, String bcc, boolean htmlFormat, String subject, String body)
    {
    
        
Properties properties = System.getProperties();
        
properties.put("mail.smtps.host", server);
        
properties.put("mail.smtps.auth", "true");
        
Session ses  = Session.getInstance(properties);

        
ses.setDebug(true);

        try{
        
            
MimeMessage msg = new MimeMessage(ses);
    
            
msg.setFrom(new InternetAddress(fromAddress));
    
            if (
toAddress != null)
            {
               
msg.addRecipients(Message.RecipientType.TO, toAddress);
            }
    
            if (
cc != null)
            {
                
msg.setRecipients(Message.RecipientType.CC
                        
,InternetAddress.parse(cc, false));
            }
    
            if (
bcc != null)
            {
                
msg.setRecipients(Message.RecipientType.BCC
                        
,InternetAddress.parse(bcc, false));
            }
    
            if (
htmlFormat)
            {
                
msg.setContent(body, "text/html");
            }
            else
            {
                
msg.setContent(body, "text/plain");
            }
    
            
msg.setSubject(subject);
            
msg.saveChanges();
    
            
Transport tr = ses.getTransport("smtps");
            
tr.connect(server,userName, password);
            
tr.sendMessage(msg, msg.getAllRecipients());
            
tr.close();
        }
        
        catch(
MessagingException e)
        {
            
e.printStackTrace();
        }
        
        

    }
}

class 
MyPasswordAuthenticator extends Authenticator
{
   
String user;
   
String pw;

   public 
MyPasswordAuthenticator (String username, String password)
   {
      
super();
      
this.user = username;
      
this.pw = password;
   }
   public 
PasswordAuthentication getPasswordAuthentication()
   {
      return new 
PasswordAuthentication(user, pw);
   }
} 
saludos,