org.apache.commons.mail.ImageHtmlEmail Java Examples
The following examples show how to use
org.apache.commons.mail.ImageHtmlEmail.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EmailManager.java From Notebook with Apache License 2.0 | 6 votes |
private void attachFile(ImageHtmlEmail email, EmailFrom emailFrom) { if(!emailFrom.isAttached()){ return; } // �������� EmailAttachment attachment = new EmailAttachment(); // ����·�� attachment.setPath(emailFrom.getAttachmentPath()); // ����·�� // attachment.setURL(new URL("http://www.baidu.com/xx.zip")); attachment.setDisposition(EmailAttachment.ATTACHMENT); // �������� // attachment.setDescription("����Ͷ�帽��"); // �������� attachment.setName(emailFrom.getAttachmentName()); // ������Ӷ������ // email.attach(attachment1); // email.attach(attachment2); try { email.attach(attachment); } catch (EmailException e) { e.printStackTrace(); } }
Example #2
Source File: EmailServiceThrowingException.java From estatio with Apache License 2.0 | 6 votes |
private boolean sendMessage( final ImageHtmlEmail email, final int backoffIntervalMs, final int numBackoffIntervals) { try { email.send(); return true; } catch (EmailException ex) { if(backoffIntervalMs == 0) { LOG.error(String.format( "Failed to send an email after %d attempts; giving up", numBackoffIntervals), ex); throw new RuntimeException(ex); } LOG.warn(String.format( "Failed to send an email; sleeping for %d seconds then will retry", backoffIntervalMs), ex); sleep(backoffIntervalMs); return false; } }
Example #3
Source File: EmailManager.java From Notebook with Apache License 2.0 | 5 votes |
private void sendBatch(EmailFrom emailFrom, List<String> list, String _url, String html) { try { String[] emails = new String[list.size()]; list.toArray(emails); ImageHtmlEmail email = createImageEmail(emailFrom, _url, html); email.addTo(emails); attachFile(email, emailFrom); email.send(); } catch (Exception e) { e.printStackTrace(); } }
Example #4
Source File: EmailManager.java From Notebook with Apache License 2.0 | 5 votes |
private void sendSingle(EmailFrom emailFrom, String singleEmail, String _url, String html) { try { ImageHtmlEmail email = createImageEmail(emailFrom, _url, html); email.addTo(singleEmail); attachFile(email, emailFrom); email.send(); } catch (Exception e) { e.printStackTrace(); } }
Example #5
Source File: EmailManager.java From Notebook with Apache License 2.0 | 5 votes |
private ImageHtmlEmail createImageEmail(EmailFrom emailFrom, String _url, String html) throws Exception { ImageHtmlEmail email = new ImageHtmlEmail(); email.setCharset("UTF-8"); URL url = new URL(_url); email.setDataSourceResolver(new DataSourceUrlResolver(url)); email.setHostName(emailFrom.getHostName()); email.setSmtpPort(emailFrom.getSmtpPort()); email.setAuthenticator(new DefaultAuthenticator(emailFrom.getUser(), emailFrom.getPwd())); email.setSSLOnConnect(true); email.setFrom(emailFrom.getFromAddr(), emailFrom.getFromNick()); email.setSubject(emailFrom.getSubject()); email.setTextMsg(emailFrom.getText()); email.setHtmlMsg(html); return email; }
Example #6
Source File: InsecureSmtpSsl.java From Android_Code_Arbiter with GNU Lesser General Public License v3.0 | 5 votes |
public static void main(String[] args) throws Exception { Email email = new SimpleEmail(); email.setHostName("smtp.googlemail.com"); email.setSSLOnConnect(false); //OK Email email2 = new SimpleEmail(); email2.setHostName("smtp2.googlemail.com"); email2.setSSLOnConnect(true); //BAD //email2.setSmtpPort(465); //email2.setAuthenticator(new DefaultAuthenticator("username", "password")); //email2.setFrom("[email protected]"); //email2.setSubject("TestMail"); //email2.setMsg("This is a test mail ... :-)"); //email2.addTo("[email protected]"); //email2.send(); MultiPartEmail emailMulti = new MultiPartEmail(); emailMulti.setHostName("mail.myserver.com"); emailMulti.setSSLOnConnect(true); //BAD HtmlEmail htmlEmail = new HtmlEmail(); htmlEmail.setHostName("mail.myserver.com"); htmlEmail.setSSLOnConnect(true); //BAD ImageHtmlEmail imageEmail = new ImageHtmlEmail(); imageEmail.setHostName("mail.myserver.com"); imageEmail.setSSLOnConnect(true); imageEmail.setSSLCheckServerIdentity(true); //OK ImageHtmlEmail imageEmail2 = new ImageHtmlEmail(); imageEmail2.setHostName("mail2.myserver.com"); imageEmail2.setSSLCheckServerIdentity(true); //OK - reversed order imageEmail2.setSSLOnConnect(true); ImageHtmlEmail imageEmail3 = new ImageHtmlEmail(); imageEmail3.setHostName("mail3.myserver.com"); imageEmail3.setSSLOnConnect(true); //BAD }
Example #7
Source File: EmailServiceThrowingException.java From estatio with Apache License 2.0 | 5 votes |
private boolean buildAndSendMessage( final List<String> toList, final List<String> ccList, final List<String> bccList, final String from, final String subject, final String body, final DataSource[] attachments, final int backoffIntervalMs, final int numBackoffIntervals) { final ImageHtmlEmail email = buildMessage( toList, ccList, bccList, from, subject, body, attachments); return sendMessage(email, backoffIntervalMs, numBackoffIntervals); }