import java.text.MessageFormat;
import java.util.Map;
-import javax.annotation.Resource;
import javax.mail.MessagingException;
import javax.mail.Session;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
import org.mxchange.jmailee.model.delivery.BaseMailer;
/**
* Email session
*/
- @Resource (name = "jmail/addressbook", description = "A JavaMail resource")
- private Session mailSession;
+ private final Session mailSession;
+
+ /**
+ * Default constructor
+ * <p>
+ * @throws javax.naming.NamingException If the JNDI name is not found
+ */
+ public AddressbookMailer () throws NamingException {
+ // Get initial context
+ Context context = new InitialContext();
+
+ // Try to lookup
+ this.mailSession = (Session) context.lookup("java:global/jfinancials-mailer/smtpSession"); //NOI18N
+ }
@Override
public void sendDeliverableMail (final WrapableEmailDelivery emailWrapper) throws MessagingException {
if (null == emailWrapper) {
// Throw NPE
throw new NullPointerException("emailWrapper is null"); //NOI18N
- } else if (emailWrapper.getRecipient() == null) {
+ } else if (emailWrapper.getRecipientAddress() == null) {
// Throw NPE again
- throw new NullPointerException("emailWrapper.recipient is null"); //NOI18N
+ throw new NullPointerException("emailWrapper.recipientAddress is null"); //NOI18N
} else if (emailWrapper.getSubjectLine() == null) {
// ... and again
throw new NullPointerException("emailWrapper.subjectLine is null"); //NOI18N