Class AlfrescoJavaMailSender

java.lang.Object
org.springframework.mail.javamail.JavaMailSenderImpl
org.alfresco.repo.mail.AlfrescoJavaMailSender
All Implemented Interfaces:
org.springframework.mail.javamail.JavaMailSender, org.springframework.mail.MailSender

public class AlfrescoJavaMailSender extends org.springframework.mail.javamail.JavaMailSenderImpl
This class extends Spring's JavaMailSenderImpl to pool the Transports used to send emails. This is to overcome problems reported in CLOUD-313.
Author:
Alex Miller
  • Field Summary

    Fields inherited from class org.springframework.mail.javamail.JavaMailSenderImpl

    DEFAULT_PORT, DEFAULT_PROTOCOL
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected jakarta.mail.Transport
    getTransport(jakarta.mail.Session session)
     
    void
    setMaxActive(int maxActive)
    Set the maximum number of active transports, managed by the pool.
    void
    setMaxIdle(int maxIdle)
    Set the maximum number of transports that can sit idle in the pool.
    void
    setMaxWait(long maxWait)
    Set the maximum amount of time (in milliseconds) to wait for a transport to be returned from the pool.
    void
    Set the minimum amount of time a transport may sit idle, before it is eligible for eviction.
    void
    setPassword(String password)
     
    void
    Set the time (in milliseconds) between runs of the idle object eviction thread.
    void
    setUsername(String userName)
     

    Methods inherited from class org.springframework.mail.javamail.JavaMailSenderImpl

    connectTransport, createMimeMessage, createMimeMessage, doSend, getDefaultEncoding, getDefaultFileTypeMap, getHost, getJavaMailProperties, getPassword, getPort, getProtocol, getSession, getUsername, send, send, setDefaultEncoding, setDefaultFileTypeMap, setHost, setJavaMailProperties, setPort, setProtocol, setSession, testConnection

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.springframework.mail.javamail.JavaMailSender

    send, send, send

    Methods inherited from interface org.springframework.mail.MailSender

    send
  • Constructor Details

    • AlfrescoJavaMailSender

      public AlfrescoJavaMailSender()
  • Method Details

    • getTransport

      protected jakarta.mail.Transport getTransport(jakarta.mail.Session session) throws jakarta.mail.NoSuchProviderException
      Overrides:
      getTransport in class org.springframework.mail.javamail.JavaMailSenderImpl
      Returns:
      A new PooledTransportWrapper which borrows a pooled Transport on connect, and returns it to the pool on close.
      Throws:
      jakarta.mail.NoSuchProviderException
    • setMaxActive

      public void setMaxActive(int maxActive)
      Set the maximum number of active transports, managed by the pool. Use a negative value for no limit. Default is -1.
    • setMaxIdle

      public void setMaxIdle(int maxIdle)
      Set the maximum number of transports that can sit idle in the pool. Use a negative value for no limit. Default is 8.
    • setMaxWait

      public void setMaxWait(long maxWait)
      Set the maximum amount of time (in milliseconds) to wait for a transport to be returned from the pool. Set to 0 or less to block indefinitely.
    • setTimeBetweenEvictionRuns

      public void setTimeBetweenEvictionRuns(long time)
      Set the time (in milliseconds) between runs of the idle object eviction thread. Set to non-positive for no eviction. Default value is 30 seconds.
    • setMinEvictableIdleTime

      public void setMinEvictableIdleTime(long time)
      Set the minimum amount of time a transport may sit idle, before it is eligible for eviction. Set to non positive prevent eviction based on idle time. This value has no affect if timeBetweenEvictionRuns is non positive. Default value is 30 seconds.
    • setUsername

      public void setUsername(String userName)
      Overrides:
      setUsername in class org.springframework.mail.javamail.JavaMailSenderImpl
    • setPassword

      public void setPassword(String password)
      Overrides:
      setPassword in class org.springframework.mail.javamail.JavaMailSenderImpl