mail = m;
}
@Override
public void run() {
final MailerAPI api = plugin.email();
api.setSubject(mail.getSubject());
api.setRecipient(mail.getRecipients());
if (mail.getCc() != null) {
api.setCc(mail.getCc());
}
if (mail.getBcc() != null) {
api.setBcc(mail.getBcc());
}
api.setFrom(mail.getFrom());
if (includeXMailerHeader) {
api.addHeader("X-Mailer", MAILER + getVersion());
}
for (final Entry<String, List<String>> entry : mail
.getCustomHeaders().entrySet()) {
final String headerName = entry.getKey();
for (final String headerValue : entry.getValue()) {
api.addHeader(headerName, headerValue);
}
}
if (mail.getReplyTo() != null) {
api.setReplyTo(mail.getReplyTo());
}
for (final Mail.Attachment attachment : mail.getAttachments()) {
if (attachment.getData() != null) {
api.addAttachment(attachment.getName(), attachment.getData(), attachment.getMimeType(), attachment.getDescription(), attachment.getDisposition());
} else {
api.addAttachment(attachment.getName(), attachment.getFile(), attachment.getDescription(), attachment.getDisposition());
}
}
if (mail.getBody().isBoth()) {
// sends both text and html
api.send(mail.getBody().getText(), mail.getBody().getHtml());
} else if (mail.getBody().isText()) {
// sends text/text
api.send(mail.getBody().getText());
} else {
// if(mail.isHtml())
// sends html
api.sendHtml(mail.getBody().getHtml());
}
}