use of teammates.logic.core.JavamailService in project teammates by TEAMMATES.
the class EmailSenderTest method testConvertToMimeMessage.
@Test
public void testConvertToMimeMessage() throws Exception {
EmailWrapper wrapper = getTypicalEmailWrapper();
MimeMessage email = new JavamailService().parseToEmail(wrapper);
assertEquals(new InternetAddress(wrapper.getSenderEmail(), wrapper.getSenderName()), email.getFrom()[0]);
assertEquals(new InternetAddress(wrapper.getReplyTo()), email.getReplyTo()[0]);
assertEquals(new InternetAddress(wrapper.getRecipient()), email.getRecipients(Message.RecipientType.TO)[0]);
assertEquals(new InternetAddress(wrapper.getBcc()), email.getRecipients(Message.RecipientType.BCC)[0]);
assertEquals(wrapper.getSubject(), email.getSubject());
assertEquals(wrapper.getContent(), email.getContent().toString());
}
use of teammates.logic.core.JavamailService in project teammates by TEAMMATES.
the class EmailSender method sendEmailCopyWithJavamail.
/**
* Sends the given {@code message} with Javamail service regardless of configuration.
*/
private void sendEmailCopyWithJavamail(EmailWrapper message) throws EmailSendingException {
// GAE Javamail is used when we need a service that is not prone to configuration failures
// and/or third-party API failures. The trade-off is the very little quota of 100 emails per day.
JavamailService javamailService = new JavamailService();
// GAE Javamail requires the sender email address to be of this format
message.setSenderEmail("admin@" + Config.getAppId() + ".appspotmail.com");
message.setSubject("[Javamail Copy] " + message.getSubject());
javamailService.sendEmail(message);
}
Aggregations