/** * D E M O * * @param args * @throws MessagingException */ public static void main( String[] args ) throws MessagingException { MailSender mailer = new MailSender(); String[] recipients = {"skerrien@ebi.ac.uk"}; mailer.postMail( recipients, "test from java", "content", "skerrien@ebi.ac.uk" ); } }
/** * D E M O * * @param args * @throws javax.mail.MessagingException */ public static void main( String[] args ) throws MessagingException { uk.ac.ebi.intact.util.MailSender mailer = new uk.ac.ebi.intact.util.MailSender(GMAIL_SETTINGS); String[] recipients = {"baranda@ebi.ac.uk"}; PasswordAuthentication auth = new PasswordAuthentication("xxx", "xxx"); mailer.postMailSSL( recipients, "test from java", "<br>content</br>", "baranda@ebi.ac.uk", auth, new File("F:\\projectes\\intact-current\\sanity\\intact-sanity-commons\\src\\main\\resources\\META-INF\\xsl\\test.html"), new File("F:\\projectes\\intact-current\\commons\\intact-commons\\src\\main\\java\\uk\\ac\\ebi\\intact\\util\\MailSender.java") ); } }
/** * Send a mail to a set of recipients. * * @param recipients list of mail adresses * @param subject subject of the mail * @param message content of the mail * @param from who wrote that mail * * @throws MessagingException if the message can't be sent. */ public void postMail( String recipients[ ], String subject, String message, String from, File ... fileAttachments ) throws MessagingException { Session session = Session.getInstance(properties); postMail(session, recipients, subject, message, from, fileAttachments); }
/** * D E M O * * @param args * @throws MessagingException */ public static void main( String[] args ) throws MessagingException { MailSender mailer = new MailSender(GMAIL_SETTINGS); String[] recipients = {"baranda@ebi.ac.uk"}; PasswordAuthentication auth = new PasswordAuthentication("xxx", "xxx"); mailer.postMailSSL( recipients, "test from java", "<br>content</br>", "baranda@ebi.ac.uk", auth, new File("F:\\projectes\\intact-current\\sanity\\intact-sanity-commons\\src\\main\\resources\\META-INF\\xsl\\test.html"), new File("F:\\projectes\\intact-current\\commons\\intact-commons\\src\\main\\java\\uk\\ac\\ebi\\intact\\util\\MailSender.java") ); } }
/** * Send a mail to a set of recipients. * * @param recipients list of mail adresses * @param subject subject of the mail * @param message content of the mail * @param from who wrote that mail * * @throws MessagingException if the message can't be sent. */ public void postMail( String recipients[ ], String subject, String message, String from ) throws MessagingException { Session session = Session.getInstance(properties); postMail(session, recipients, subject, message, from, null); }
/** * Send a mail to a set of recipients. * * @param recipients list of mail adresses * @param subject subject of the mail * @param message content of the mail * @param from who wrote that mail * * @throws MessagingException if the message can't be sent. */ public void postMailSSL( String recipients[ ], String subject, String message, String from, final PasswordAuthentication auth ) throws MessagingException { Session session = Session.getDefaultInstance(properties, new javax.mail.Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { return auth; } }); postMail(session, recipients, subject, message, from, null); }
/** * Send a mail to a set of recipients. * * @param recipients list of mail adresses * @param subject subject of the mail * @param message content of the mail * @param from who wrote that mail * * @throws MessagingException if the message can't be sent. */ public void postMailSSL( String recipients[ ], String subject, String message, String from, final PasswordAuthentication auth, File ... fileAttachment ) throws MessagingException { Session session = Session.getDefaultInstance(properties, new javax.mail.Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { return auth; } }); postMail(session, recipients, subject, message, from, fileAttachment); }