List of usage examples for org.apache.commons.mail HtmlEmail addTo
public Email addTo(final String email, final String name) throws EmailException
From source file:org.oscarehr.util.EmailUtils.java
/** * This main method is useful when debugging smtp configuration problems. *//*from w ww. j a va 2 s . com*/ public static void main(String... argv) throws EmailException { // gmail : smtp.gmail.com:465 String fromEmailAddress = argv[0]; String toEmailAddress = argv[1]; String smtpServer = argv[2]; String smtpPort = (argv.length > 3 ? argv[3] : null); String smtpUser = (argv.length > 4 ? argv[4] : null); String smtpPassword = (argv.length > 5 ? argv[4] : null); String connectionSecurity = (argv.length > 6 ? argv[5] : null); HtmlEmail htmlEmail = EmailUtils.getHtmlEmail(smtpServer, smtpPort, smtpUser, smtpPassword, connectionSecurity); htmlEmail.addTo(toEmailAddress, toEmailAddress); htmlEmail.setFrom(fromEmailAddress, fromEmailAddress); htmlEmail.setSubject("test subject"); htmlEmail.setTextMsg("test contents " + (new java.util.Date())); htmlEmail.send(); }
From source file:org.oscarehr.util.EmailUtilsOld.java
/** * This main method is useful when debugging smtp configuration problems. *///from ww w . j ava2 s . c om public static void main(String... argv) throws EmailException { // gmail : smtp.gmail.com:465 String fromEmailAddress = argv[0]; String toEmailAddress = argv[1]; String smtpServer = argv[2]; String smtpPort = (argv.length > 3 ? argv[3] : null); String smtpUser = (argv.length > 4 ? argv[4] : null); String smtpPassword = (argv.length > 5 ? argv[4] : null); String connectionSecurity = (argv.length > 6 ? argv[5] : null); HtmlEmail htmlEmail = EmailUtilsOld.getHtmlEmail(smtpServer, smtpPort, smtpUser, smtpPassword, connectionSecurity); htmlEmail.addTo(toEmailAddress, toEmailAddress); htmlEmail.setFrom(fromEmailAddress, fromEmailAddress); htmlEmail.setSubject("test subject"); htmlEmail.setTextMsg("test contents " + (new java.util.Date())); htmlEmail.send(); }
From source file:org.yestech.notify.deliver.HtmlEmailDelivery.java
protected void sendMessage(INotification notification, IRecipient recipient) throws EmailException { // Create the email message HtmlEmail email = new HtmlEmail(); enableAuthenticator(email);/* ww w. ja v a2 s .com*/ email.setHostName(getEmailHost()); ISender sender = notification.getSender(); email.setFrom(sender.getEmailAddress(), sender.getDisplayName()); if (StringUtils.isNotBlank(sender.getReplyAddress())) { email.addReplyTo(sender.getReplyAddress()); } email.setSubject(notification.getMessage().getSubject()); email.addTo(recipient.getEmailAddress(), recipient.getDisplayName()); ITemplateLanguage template = notification.getTemplate(); String appliedMessage = template.apply(notification.getMessage()); email.setHtmlMsg(appliedMessage); email.send(); }