org.mmbase.applications.email
Class SendMail

java.lang.Object
  extended by org.mmbase.util.functions.FunctionProvider
      extended by org.mmbase.util.functions.DescribedFunctionProvider
          extended by org.mmbase.module.Module
              extended by org.mmbase.module.ReloadableModule
                  extended by org.mmbase.module.WatchedReloadableModule
                      extended by org.mmbase.applications.email.AbstractSendMail
                          extended by org.mmbase.applications.email.SendMail
All Implemented Interfaces:
Descriptor

public class SendMail
extends AbstractSendMail

Module providing mail functionality based on JavaMail, mail-resources.

Since:
MMBase-1.6
Version:
$Id: SendMail.java 42270 2010-05-26 08:29:38Z michiel $
Author:
Case Roole, Michiel Meeuwissen, Daniel Ockeloen, Johannes Verelst <johannes.verelst@eo.nl>

Field Summary
static String DEFAULT_MAIL_ENCODING
           
static long emailFailed
           
static long emailSent
           
static String mailEncoding
           
protected static Set<String> RECOGNIZED_HEADERS
           
protected  javax.mail.Session session
           
 
Fields inherited from class org.mmbase.module.Module
configurationPath, getMaintainerFunction, getVersionFunction, properties, STATE_START_TIME
 
Fields inherited from class org.mmbase.util.functions.DescribedFunctionProvider
description, guiName, name
 
Fields inherited from class org.mmbase.util.functions.FunctionProvider
functions, getFunctions
 
Constructor Summary
SendMail()
           
SendMail(String name)
           
 
Method Summary
protected  javax.mail.internet.MimeMessage constructMessage(String from, javax.mail.internet.InternetAddress[] to, Map<String,String> headers)
          Utility method to do the generic job of creating a MimeMessage object and setting its recipients and 'from'.
protected  Set<String> getDomains()
          Returns the domains that are te be consided 'local' domains.
 String getModuleInfo()
          Provide some info on the module; By default, this returns the module description for the default locale
 javax.mail.Session getSession()
           
 String getTypeField()
           
 void init()
          Initializes the module.
protected  boolean isLocal(javax.mail.internet.InternetAddress recipient)
           
protected  javax.mail.internet.InternetAddress[] parseOnly(String to)
          Like InternetAddress#parse but leaves out the addresses not matching 'onlyTo'.
 void reload()
          This method should be called when the module should be reloaded.
 void sendLocalMail(javax.mail.internet.InternetAddress[] to, Node n)
          Delivers the mail represented by an MMBase node 'locally'.
 boolean sendMail(Node n)
          Send mail with headers AND attachments
 boolean sendMail(String onlyto, Node n)
          Send mail with headers AND attachments to the emailaddresses specified in the 'to' and 'cc' fields.
 boolean sendMail(String from, String to, String data, Map<String,String> headers)
          Send mail with headers, withouth using any explicit nodes.
 boolean sendMultiPartMail(String from, String to, Map<String,String> headers, javax.mail.internet.MimeMultipart mmpart)
          Sends a 'multipart' mail.
protected  void sendRemoteMail(javax.mail.internet.InternetAddress[] onlyto, javax.mail.Address sender, Node n)
          Sends an email which is represented by an MMBase node.
protected  void sendRemoteMail(javax.mail.internet.InternetAddress[] onlyto, Node n)
           
 
Methods inherited from class org.mmbase.applications.email.AbstractSendMail
sendMail, sendMail
 
Methods inherited from class org.mmbase.module.WatchedReloadableModule
onload
 
Methods inherited from class org.mmbase.module.ReloadableModule
reloadConfiguration, reloadConfiguration
 
Methods inherited from class org.mmbase.module.Module
addInitParameters, checkModules, getInitParameter, getInitParameter, getInitParameter, getInitParameters, getInitParameters, getMaintainer, getModule, getModule, getModule, getModule, getModuleLoader, getModuleReader, getModuleReader, getModules, getState, getStates, getVersion, hasModule, hasStarted, loadInitParameters, loadInitParameters, maintainance, setInitParameter, setMaintainer, setState, setVersion, shutdown, shutdownModules, startModule, startModules
 
Methods inherited from class org.mmbase.util.functions.DescribedFunctionProvider
getDefaultLocale, getDescription, getDescription, getGUIName, getGUIName, getLocalizedDescription, getLocalizedGUIName, getName, setDescription, setDescription, setGUIName, setGUIName, setLocalizedDescription, setLocalizedGUIName, setName
 
Methods inherited from class org.mmbase.util.functions.FunctionProvider
addFunction, createParameters, getFunction, getFunctions, getFunctionValue, newFunctionInstance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_MAIL_ENCODING

public static final String DEFAULT_MAIL_ENCODING
See Also:
Constant Field Values

mailEncoding

public static String mailEncoding

emailSent

public static long emailSent

emailFailed

public static long emailFailed

session

protected javax.mail.Session session

RECOGNIZED_HEADERS

protected static final Set<String> RECOGNIZED_HEADERS
Constructor Detail

SendMail

public SendMail()

SendMail

public SendMail(String name)
Method Detail

getDomains

protected Set<String> getDomains()
Returns the domains that are te be consided 'local' domains. If the SMTPModule is not active, then this retuns an empty set.

Since:
MMBase-1.9

sendLocalMail

public void sendLocalMail(javax.mail.internet.InternetAddress[] to,
                          Node n)
Delivers the mail represented by an MMBase node 'locally'. I.e. no actual mail is sent (unless forwarded), but new objects and relations are created, to make this mail appear in the mailbox of the recipients (which are represented by other MMBase nodes). The given 'body' of the node is _not_ parsed. MultiParts should be indicated by mmbase relations.

Since:
MMBase-1.9

parseOnly

protected javax.mail.internet.InternetAddress[] parseOnly(String to)
                                                   throws javax.mail.MessagingException
Like InternetAddress#parse but leaves out the addresses not matching 'onlyTo'.

Throws:
javax.mail.MessagingException

sendMultiPartMail

public boolean sendMultiPartMail(String from,
                                 String to,
                                 Map<String,String> headers,
                                 javax.mail.internet.MimeMultipart mmpart)
                          throws javax.mail.MessagingException
Description copied from class: AbstractSendMail
Sends a 'multipart' mail.

Specified by:
sendMultiPartMail in class AbstractSendMail
Returns:
Always true Could in principle return false on failure. But that would normally result an exception.
Throws:
javax.mail.MessagingException

getModuleInfo

public String getModuleInfo()
Provide some info on the module; By default, this returns the module description for the default locale

Overrides:
getModuleInfo in class Module

reload

public void reload()
Description copied from class: ReloadableModule
This method should be called when the module should be reloaded.

Specified by:
reload in class ReloadableModule

init

public void init()
Initializes the module. Init must be overridden to read the environment variables it needs.
This method is called by Module.startModule(), which makes sure it is not called more than once. You should not call init() directly, call startModule() instead.

Overrides:
init in class Module

constructMessage

protected final javax.mail.internet.MimeMessage constructMessage(String from,
                                                                 javax.mail.internet.InternetAddress[] to,
                                                                 Map<String,String> headers)
                                                          throws javax.mail.MessagingException
Utility method to do the generic job of creating a MimeMessage object and setting its recipients and 'from'.

Throws:
javax.mail.MessagingException

sendMail

public boolean sendMail(String from,
                        String to,
                        String data,
                        Map<String,String> headers)
Send mail with headers, withouth using any explicit nodes.

Specified by:
sendMail in class AbstractSendMail

sendRemoteMail

protected void sendRemoteMail(javax.mail.internet.InternetAddress[] onlyto,
                              Node n)
Since:
MMBase-1.9

sendRemoteMail

protected void sendRemoteMail(javax.mail.internet.InternetAddress[] onlyto,
                              javax.mail.Address sender,
                              Node n)
Sends an email which is represented by an MMBase node. The given 'body' of the node is _not_ parsed. MultiParts should be indicated by mmbase relations.

Parameters:
sender - If this is a forward, then you'd want to set the sender to the local address (see rfc 822 4.4.4)
Since:
MMBase-1.9

sendMail

public boolean sendMail(Node n)
Send mail with headers AND attachments

Since:
MMBase-1.9

isLocal

protected boolean isLocal(javax.mail.internet.InternetAddress recipient)

sendMail

public boolean sendMail(String onlyto,
                        Node n)
Send mail with headers AND attachments to the emailaddresses specified in the 'to' and 'cc' fields. If these are null, the values from the 'to' and 'cc' fields from the node are used.

Since:
MMBase-1.9

getSession

public javax.mail.Session getSession()

getTypeField

public String getTypeField()


MMBase 2.0-SNAPSHOT - null