protected SimpleEmail createTextOnlyEmail(String text) { SimpleEmail email = new SimpleEmail(); try { email.setMsg(text); return email; } catch (EmailException e) { throw new ActivitiException("Could not create text-only email", e); } }
/** * @param subject 主题 * @param body 内容 * @param recipients 收件人 */ public static SimpleEmail getSimpleEmail(String subject, String body, String... recipients) throws EmailException { SimpleEmail simpleEmail = new SimpleEmail(); configEmail(subject, simpleEmail, recipients); if (body != null) simpleEmail.setMsg(body); return simpleEmail; }
+ StringUtils.defaultString(emailMessage.getSubject(), SUBJECT_DEFAULT); email.setSubject(subject); email.setMsg(emailMessage.getMessage());
protected SimpleEmail createTextOnlyEmail(String text) { SimpleEmail email = new SimpleEmail(); try { email.setMsg(text); return email; } catch (EmailException e) { throw LOG.emailCreationException("text-only", e); } }
protected SimpleEmail createTextOnlyEmail(String text) { SimpleEmail email = new SimpleEmail(); try { email.setMsg(text); return email; } catch (EmailException e) { throw LOG.emailCreationException("text-only", e); } }
SimpleEmail email = new SimpleEmail(); email.setHostName("mail.myserver.com"); email.addTo("jdoe@somewhere.org", "John Doe"); email.setFrom("me@apache.org", "Me"); email.setSubject("Test message"); email.setMsg("This is a simple test of commons-email"); email.send();
protected SimpleEmail createTextOnlyEmail(String text) { SimpleEmail email = new SimpleEmail(); try { email.setMsg(text); return email; } catch (EmailException e) { throw new ActivitiException("Could not create text-only email", e); } }
protected SimpleEmail createTextOnlyEmail(String text) { SimpleEmail email = new SimpleEmail(); try { email.setMsg(text); return email; } catch (EmailException e) { throw new ActivitiException("Could not create text-only email", e); } }
protected SimpleEmail createTextOnlyEmail(String text) { SimpleEmail email = new SimpleEmail(); try { email.setMsg(text); return email; } catch (EmailException e) { throw new FlowableException("Could not create text-only email", e); } }
protected SimpleEmail createTextOnlyEmail(String text) { SimpleEmail email = new SimpleEmail(); try { email.setMsg(text); return email; } catch (EmailException e) { throw LOG.emailCreationException("text-only", e); } }
protected SimpleEmail createTextOnlyEmail(String text) { SimpleEmail email = new SimpleEmail(); try { email.setMsg(text); return email; } catch (EmailException e) { throw new ActivitiException("Could not create text-only email", e); } }
@Override public void sendPlainTextEmail(final List<String> to, final List<String> cc, final String subject, final String body) throws IOException, EmailApiException { final SimpleEmail email = new SimpleEmail(); try { email.setMsg(body); } catch (EmailException e) { throw new EmailApiException(e, ErrorCode.EMAIL_SENDING_FAILED); } sendEmail(to, cc, subject, email); }
private void sendTextMail(String fromEmail, String fromPasswd,String fromName, String host,List<String> toEmailList,MailMsg mailMsg){ SimpleEmail email = new SimpleEmail(); try { initEmail(email, fromEmail, fromPasswd,fromName, host, toEmailList, mailMsg); email.setMsg(mailMsg.getContent()); email.send(); } catch (EmailException e) { e.printStackTrace(); } }
SimpleEmail email = new SimpleEmail(); email.setHostName("mail.myserver.com"); email.addTo("jdoe@somewhere.org", "John Doe"); email.setFrom("me@apache.org", "Me"); email.setSubject("Test message"); email.setMsg("This is a simple test of commons-email"); email.send();
simpleEmail.setMsg(renderEmail(emailTemplate.getTextBody(), context).toString()); email = simpleEmail; } else if (HTML == mimeType) {
public Document processDocument(Document doc) throws DocumentProcessorException { SimpleEmail email = new SimpleEmail(); email.setHostName(hostName); try { email.addTo(to); email.setFrom(from); email.setSubject("Document"); email.setMsg(doc.getPrintRepresentation()); email.send(); } catch (EmailException e) { throw new DocumentProcessorException(e); } return doc; }
/** * A sanity check that a simple email also works in reality. * * @throws Exception the test failed */ @Test public void testSimpleEmail() throws Exception { final SimpleEmail email = (SimpleEmail) create(SimpleEmail.class); email.setSubject("TestSimpleMail"); email.setMsg("This is a test mail ... :-)"); EmailUtils.writeMimeMessage( new File("./target/test-emails/simplemail.eml"), send(email).getMimeMessage()); }
/** * A sanity check that a header folding works correctly. * * @throws Exception the test failed */ @Test public void testFoldedHeaderValue() throws Exception { final SimpleEmail email = (SimpleEmail) create(SimpleEmail.class); email.setSubject("TestFoldedHeaderMail"); email.setMsg("This is a test mail with a folded header value... :-)"); email.addHeader("X-TestHeader", "This is a very long header value which should be folded into two lines, hopefully"); EmailUtils.writeMimeMessage( new File("./target/test-emails/foldedheader.eml"), send(email).getMimeMessage()); }
personalizedEmail.setMailSession(session); personalizedEmail.setSubject("Personalized Test Mail Nr. " + i); personalizedEmail.setMsg("This is a personalized test mail ... :-)"); personalizedEmail.buildMimeMessage(); emails.add(personalizedEmail);
/** * Testing if we are able to send a partial email with an invalid address. * * https://issues.apache.org/jira/browse/EMAIL-132 * * @throws Exception the test failed. */ @Test public void testPartialSend() throws Exception { final SimpleEmail email = (SimpleEmail) create(SimpleEmail.class); email.addTo(EmailConfiguration.TEST_TO); email.addTo("nobody@is.invalid"); email.setSubject("TestPartialMail"); email.setMsg("This is a test mail ... :-)"); email.setSendPartial(true); EmailUtils.writeMimeMessage( new File("./target/test-emails/partialmail.eml"), send(email).getMimeMessage()); }