001/* 002 * DO NOT REMOVE COPYRIGHT NOTICES OR THIS HEADER. 003 * 004 * The contents of this file are subject to the terms 005 * of the Common Development and Distribution License 006 * (the License). You may not use this file except in 007 * compliance with the License. 008 * 009 * You can obtain a copy of the License at 010 * http://forgerock.org/license/CDDLv1.0.html 011 * See the License for the specific language governing 012 * permission and limitations under the License. 013 * 014 * When distributing Covered Code, include this CDDL 015 * Header Notice in each file and include the License file 016 * at http://forgerock.org/license/CDDLv1.0.html 017 * If applicable, add the following below the CDDL Header, 018 * with the fields enclosed by brackets [] replaced by 019 * your own identifying information: 020 * "Portions copyright [year] [name of copyright owner]" 021 * 022 * Copyright 2013-2015 ForgeRock AS. 023 */ 024 025package org.forgerock.openam.services.email; 026 027import javax.mail.MessagingException; 028import java.util.Map; 029import java.util.Set; 030 031/** 032 * Pluggable interface for all email sending in OpenAM. Can be configured on a per-realm or global basis via the 033 * {@code forgerockMailServerImplClassName} attribute of the Email Service. 034 * <p> 035 * The implementation <strong>must</strong> provide a constructor taking a single String argument, which is the name 036 * of the realm that service is being constructed for. 037 * 038 * @supported.all.api 039 */ 040public interface MailServer { 041 042 /** 043 * Sends an email message, containing HTML, using default MailServer settings. 044 * 045 * @param to The address that the E-mail message is sent. 046 * @param subject The E-mail subject. 047 * @param message The content contained in the E-mail message. 048 * @throws MessagingException in the case where the module was unable to send the e-mail. 049 */ 050 void sendHtmlEmail(String to, String subject, String message) throws MessagingException; 051 052 /** 053 * Sends an email message, containing HTML, using specified options given 054 * for the MailServer settings. 055 * 056 * @param from The address that sends the E-mail message. 057 * @param to The address that the E-mail message is sent. 058 * @param subject The E-mail subject. 059 * @param message The content contained in the E-mail message. 060 * @param options SMTPHostName, SMTPPort, SMTPUser, SMTPUserPassword. 061 * @throws MessagingException in case where the module was unable to send the e-mail. 062 */ 063 void sendHtmlEmail(String from, String to, String subject, String message, Map<String, Set<String>> options) 064 throws MessagingException; 065 066 /** 067 * Sends an email message using specified 068 * options given for the MailServer settings 069 * 070 * @param from The address that sends the E-mail message 071 * @param to The address that the E-mail message is sent 072 * @param subject The E-mail subject 073 * @param message The content contained in the E-mail message 074 * @param options SMTPHostName, SMTPPort, SMTPUser, SMTPUserPassword 075 * @throws MessagingException in case where the module was unable to send the e-mail 076 */ 077 void sendEmail(String from, String to, String subject, 078 String message, Map<String, Set<String>> options) throws MessagingException; 079 080 /** 081 * Sends an email message using default MailServer settings 082 * @param to The address that the E-mail message is sent 083 * @param subject The E-mail subject 084 * @param message The content contained in the E-mail message 085 * @throws MessagingException in the case where the module was unable to send the e-mail 086 */ 087 void sendEmail(String to, String subject, String message) throws MessagingException; 088 089 /** 090 * Sends an email message using default MailServer settings. 091 * 092 * @param to 093 * the address that the email message is sent 094 * @param subject 095 * the E-mail subject 096 * @param message 097 * the content contained in the email message 098 * @param mimeType 099 * the mime type to be used for the email 100 * 101 * @throws MessagingException 102 * in the case where the module was unable to send the email 103 */ 104 void sendEmail(String to, String subject, String message, String mimeType) throws MessagingException; 105 106}