Package com.logicaldoc.core.communication

# Class EMailSender

java.lang.Object
com.logicaldoc.core.communication.EMailSender

public class EMailSender extends Object
SMTP E-Mail sender service

Author:
  Michael Scholz, Matteo Caruso - LogicalDOC

## Field Summary

Fields
Modifier and Type
Field
Description
`static final int`
`FOLDERING_DAY`
`static final int`
`FOLDERING_MONTH`
`static final int`
`FOLDERING_NONE`
`static final int`
`FOLDERING_YEAR`
`static final String`
`PROTOCOL_SMTP`
`static final String`
`PROTOCOL_SMTP_MICROSOFT365`
`static final int`
`SECURITY_NONE`
`static final int`
`SECURITY_SSL`
`static final int`
`SECURITY_STARTTLS`
`static final int`
`SECURITY_TLS`

## Constructor Summary

Constructors
Constructor
Description
`EMailSender()`
`EMailSender(long tenant)`
`EMailSender(String tenant)`

## Method Summary

Modifier and Type
Method
Description
`static EMailSender`
`get()`
Gets the object available in the application context
`String`
`getClientId()`
`String`
`getClientSecret()`
`String`
`getClientTenant()`
`int`
`getConnectionSecurity()`
`Long`
`getFolderId()`
`int`
`getFoldering()`
`String`
`getHost()`
`String`
`getPassword()`
`int`
`getPort()`
`String`
`getProtocol()`
`String`
`getSender()`
`String`
`getUsername()`
`boolean`
`isAuthEncrypted()`
`void`
`send(EMail email)`
This method sends an email using the smtp-protocol.
`void`
`send(EMail email, String templateName, Map<String,Object> dictionary)`
Sends an email by using a given template
`void`
`sendAsync(EMail email)`
Same as send(EMail) but executes in another thread
`void`
`sendAsync(EMail email, String templateName, Map<String,Object> dictionary)`
Same as send(EMail, String, Map) but executes in another thread
`void`
`setAuthEncrypted(boolean authEncrypted)`
`void`
`setClientId(String clientId)`
`void`
`setClientSecret(String clientSecret)`
`void`
`setClientTenant(String clientTenant)`
`void`
`setConnectionSecurity(int connectionSecurity)`
`void`
`setFolderId(Long folderId)`
`void`
`setFoldering(int foldering)`
`void`
`setHost(String host)`
`void`
`setPassword(String password)`
`void`
`setPort(int port)`
`void`
`setProtocol(String protocol)`
`void`
`setSender(String sender)`
`void`
`setTenant(long tenant)`
`void`
`setUsername(String username)`

### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### SECURITY_NONE

public static final int SECURITY_NONE

See Also:
  - Constant Field Values

### SECURITY_STARTTLS

public static final int SECURITY_STARTTLS

See Also:
  - Constant Field Values

### SECURITY_TLS

public static final int SECURITY_TLS

See Also:
  - Constant Field Values

### SECURITY_SSL

public static final int SECURITY_SSL

See Also:
  - Constant Field Values

### PROTOCOL_SMTP

public static final String PROTOCOL_SMTP

See Also:
  - Constant Field Values

### PROTOCOL_SMTP_MICROSOFT365

public static final String PROTOCOL_SMTP_MICROSOFT365

See Also:
  - Constant Field Values

### FOLDERING_NONE

public static final int FOLDERING_NONE

See Also:
  - Constant Field Values

### FOLDERING_YEAR

public static final int FOLDERING_YEAR

See Also:
  - Constant Field Values

### FOLDERING_MONTH

public static final int FOLDERING_MONTH

See Also:
  - Constant Field Values

### FOLDERING_DAY

public static final int FOLDERING_DAY

See Also:
  - Constant Field Values

## Constructor Details

### EMailSender

public EMailSender(long tenant)

### EMailSender

public EMailSender(String tenant)

### EMailSender

public EMailSender()

## Method Details

### get

public static EMailSender get()
Gets the object available in the application context

Returns:
  the instance of this object in the application context

### setTenant

public void setTenant(long tenant)

### getSender

public String getSender()

### setSender

public void setSender(String sender)

### getHost

public String getHost()

### setHost

public void setHost(String host)

### getPassword

public String getPassword()

### setPassword

public void setPassword(String password)

### getPort

public int getPort()

### setPort

public void setPort(int port)

### getUsername

public String getUsername()

### setUsername

public void setUsername(String username)

### sendAsync

public void sendAsync(EMail email, String templateName, Map<String,Object> dictionary)
Same as send(EMail, String, Map) but executes in another thread

Parameters:
  `email` - the email to send
  `templateName` - the template to use to render the body of the message using the automation engine
  `dictionary` - map of variable to pass to the automation

### send

public void send(EMail email, String templateName, Map<String,Object> dictionary) throws jakarta.mail.MessagingException, AutomationException
Sends an email by using a given template

Parameters:
  `email` - The email to send
  `templateName` - Name of the template to be applied
  `dictionary` - The dictionary to be used in the template
Throws:
  `jakarta.mail.MessagingException` - raised if the email cannot be sent
  `AutomationException` - the automation has been evaluated but produced an error

### sendAsync

public void sendAsync(EMail email)
Same as send(EMail) but executes in another thread

Parameters:
  `email` - the email to send

### send

public void send(EMail email) throws jakarta.mail.MessagingException
This method sends an email using the smtp-protocol. The email can be a simple mail or a multipart mail containing up to 5 attachments.

Parameters:
  `email` - E-Mail which should be sent.
Throws:
  `jakarta.mail.MessagingException` - raised if the email cannot be sent

### isAuthEncrypted

public boolean isAuthEncrypted()

### setAuthEncrypted

public void setAuthEncrypted(boolean authEncrypted)

### getConnectionSecurity

public int getConnectionSecurity()

### setConnectionSecurity

public void setConnectionSecurity(int connectionSecurity)

### getFoldering

public int getFoldering()

### setFoldering

public void setFoldering(int foldering)

### getFolderId

public Long getFolderId()

### setFolderId

public void setFolderId(Long folderId)

### getProtocol

public String getProtocol()

### getClientSecret

public String getClientSecret()

### getClientId

public String getClientId()

### getClientTenant

public String getClientTenant()

### setProtocol

public void setProtocol(String protocol)

### setClientSecret

public void setClientSecret(String clientSecret)

### setClientId

public void setClientId(String clientId)

### setClientTenant

public void setClientTenant(String clientTenant)