private void setMimeContent(final Email email, final String contentStr, final String mime) throws ContentHandlerException { if ("text/plain".equals(mime)) { email.setText(contentStr); } else if ("text/html".equals(mime)) { email.setHtml(contentStr); } else { throw new ContentHandlerException("MIME type " + mime + " is not supported"); } }
@Override public void sendForInvite(IMatrixIdInvite invite) { EmailTemplate template = cfg.getTemplates().getGeneric().get("matrixId"); Email email = getEmail(); email.setSubject(populateForInvite(invite, template.getSubject())); email.setText(populateForInvite(invite, getFromFile(template.getBody().getText()))); email.setHtml(populateForInvite(invite, getFromFile(template.getBody().getHtml()))); send(invite.getAddress(), email); }
@Override public void sendForRemoteValidation(IThreePidSession session) { EmailTemplate template = cfg.getTemplates().getSession().getLocal(); Email email = getEmail(); email.setSubject(populateForRemoteValidation(session, template.getSubject())); email.setText(populateForRemoteValidation(session, getFromFile(template.getBody().getText()))); email.setHtml(populateForRemoteValidation(session, getFromFile(template.getBody().getHtml()))); send(session.getThreePid().getAddress(), email); }
@Override public void sendForValidation(IThreePidSession session) { EmailTemplate template = cfg.getTemplates().getSession().getLocal(); Email email = getEmail(); email.setSubject(populateForValidation(session, template.getSubject())); email.setText(populateForValidation(session, getFromFile(template.getBody().getText()))); email.setHtml(populateForValidation(session, getFromFile(template.getBody().getHtml()))); send(session.getThreePid().getAddress(), email); }
import com.sendgrid.*; public class SendGridExample { public static void main(String[] args) { SendGrid sendgrid = new SendGrid("SENDGRID_APIKEY"); SendGrid.Email email = new SendGrid.Email(); email.addTo("test@sendgrid.com"); email.setFrom("you@youremail.com"); email.setSubject("Sending with SendGrid is Fun"); email.setHtml("and easy to do anywhere, even with Java"); SendGrid.Response response = sendgrid.send(email); } }
@Override public void sendForReply(IThreePidInviteReply invite) { EmailTemplate template = cfg.getTemplates().getInvite(); Email email = getEmail(); email.setSubject(populateForReply(invite, template.getSubject())); email.setText(populateForReply(invite, getFromFile(template.getBody().getText()))); email.setHtml(populateForReply(invite, getFromFile(template.getBody().getHtml()))); send(invite.getInvite().getAddress(), email); }