import javax.mail.*;
import javax.mail.internet.*;
import java.util.*;


public class SimpleMail
{

    public static void main(String args[])
    {

        try
        {
            Properties props = System.getProperties();

            //add mailhost to properties
            props.put("mail.smtp.host", "PUT MAIL SERVER IP HERE");

            // Get a Session object
            Session session = Session.getDefaultInstance(props, null);

            // show debug info if flag is set to true
            session.setDebug(true);

            // construct the message
            Message msg = new MimeMessage(session);

            // set from
            msg.setFrom(new InternetAddress("from@CHANGEME-joelnylund.com"));
            msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse("to@CHANGEME-joelnylund.com",false));

            //set bcc
            msg.setRecipients(Message.RecipientType.BCC, InternetAddress.parse("bcc@CHANGEME-joelnylund.com,bcc2@CHANGEME-joelnylund.com",false));
            //set subject
            msg.setSubject("joel test email");

            //set message
            msg.setText("send joel an email if you get this");
            // msg.setHeader("X-Mailer", mailer);
            msg.setSentDate(new Date());

            // send the message
            Transport.send(msg);
        }
        catch (SendFailedException e)
        {
            System.out.println(e.getMessage());
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
    }



}


