package paqueteMail;






import java.util.Properties;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;


public class utilsMail {

    public static void enviarEmail(String destinatario,String titulo,String texto) throws MessagingException
    {
        try{
        MimeMultipart multipart = new MimeMultipart("alternative");
        Properties props = new Properties();
        props.setProperty("mail.smtp.host", "localhost");
        props.setProperty("mail.smtp.starttls.enable", "false");
        props.setProperty("mail.smtp.user", "fvc@fvc.com");
        props.setProperty("mail.smtp.auth", "true");
        Session session = Session.getDefaultInstance(props);
        session.setDebug(false);
        MimeMessage message = new MimeMessage(session);
        message.setFrom(new InternetAddress("fvc@fvc.com"));
        message.addRecipient(Message.RecipientType.TO, new InternetAddress(destinatario));
        message.setSubject(titulo);

        message.setContent(texto,"text/plain");
        Transport t = session.getTransport("smtp");
        t.connect("fvc@fvc.com","fvc");
        t.sendMessage(message,message.getAllRecipients());
        t.close();
        }
        catch(Exception e)
        {
            System.out.println("Advertencia: "+e.getMessage());
        }
    }

}

