001package de.deepamehta.plugins.mail.service; 002 003import java.io.IOException; 004import java.io.UnsupportedEncodingException; 005import java.util.Collection; 006import java.util.List; 007 008import org.apache.commons.mail.EmailException; 009 010import de.deepamehta.core.Association; 011import de.deepamehta.core.Topic; 012import de.deepamehta.core.service.PluginService; 013import de.deepamehta.plugins.mail.Mail; 014import de.deepamehta.plugins.mail.RecipientType; 015import de.deepamehta.plugins.mail.StatusReport; 016 017public interface MailService extends PluginService { 018 019 /** 020 * Returns parent of each search type. 021 * 022 * Parent types must include at least one email address. 023 * 024 * @return parent search types. 025 */ 026 Collection<Topic> getSearchParentTypes(); 027 028 /** 029 * Update or create a mail recipient association. 030 * 031 * @param mailId 032 * ID of a mail topic. 033 * @param addressId 034 * Email address of recipient. 035 * @param type 036 * Recipient type URI or null to choose the configured default. 037 * @return Recipient association with email address and recipient type. 038 */ 039 Association associateRecipient(long mailId, long addressId, RecipientType type); 040 041 /** 042 * Update or create a mail sender association. 043 * 044 * @param topicId 045 * ID of a mail or configuration topic. 046 * @param addressId 047 * Email address of sender. 048 * @return Sender association with email address. 049 */ 050 Association associateSender(long topicId, long addressId); 051 052 /** 053 * Associate all valid email addresses of each recipient. 054 * 055 * @param mailId 056 * @param recipients 057 */ 058 void associateValidatedRecipients(long mailId, List<Topic> recipients); 059 060 /** 061 * Sends a HTML mail. 062 * 063 * @param mail Mail topic. 064 * @return Sent mail topic. 065 */ 066 StatusReport send(Mail mail) throws UnsupportedEncodingException, EmailException, IOException; 067}