Uploaded image for project: 'Nuxeo Platform'
  1. Nuxeo Platform
  2. NXP-32029

Factorize email sending code

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2023.4
    • Component/s: Core, Notifications
    • Release Notes Summary:
      Introducing a new MailService leveraging contributable MailSenders to send MailMessages
    • Release Notes Description:
      Hide

      Introducing a new MailService leveraging contributable MailSenders to send MailMessages

      Configuration

      SMTPMailSender, the provided implementation of MailSender comes as default sender and will leverage the following nuxeo conf:

      • mail.debug
      • mail.from
      • mail.transport.protocol
      • mail.transport.host
      • mail.transport.port
      • mail.transport.auth
      • mail.transport.user
      • mail.transport.password
      • mail.transport.usetls
      • mail.transport.ssl.protocol

      Contributing

      Users can contribute their own MailSender like so:

      <?xml version="1.0"?>
      <component name="org.nuxeo.mail.my.sender.contrib">
        <extension target="org.nuxeo.mail.MailServiceComponent" point="senders">
      
          <sender name="mySender" class="org.nuxeo.mail.SMTPMailSender">
            <property name="mail.transport.protocol">smtp</property>
            <property name="mail.smtp.host">127.0.0.1</property>
            <property name="mail.smtp.port">587</property>
            <property name="mail.from">noreply@nuxeo.com</property>
          </sender>
      
        </extension>
      </component>
      
      Show
      Introducing a new MailService leveraging contributable MailSenders to send MailMessages Configuration SMTPMailSender, the provided implementation of MailSender comes as default sender and will leverage the following nuxeo conf: mail.debug mail.from mail.transport.protocol mail.transport.host mail.transport.port mail.transport.auth mail.transport.user mail.transport.password mail.transport.usetls mail.transport.ssl.protocol Contributing Users can contribute their own MailSender like so: <?xml version= "1.0" ?> <component name= "org.nuxeo.mail.my.sender.contrib" > <extension target= "org.nuxeo.mail.MailServiceComponent" point= "senders" > <sender name= "mySender" class= "org.nuxeo.mail.SMTPMailSender" > <property name= "mail.transport.protocol" > smtp </property> <property name= "mail.smtp.host" > 127.0.0.1 </property> <property name= "mail.smtp.port" > 587 </property> <property name= "mail.from" > noreply@nuxeo.com </property> </sender> </extension> </component>
    • Tags:
    • Upgrade notes:
      Hide

      Compatibility with custom jndi sessions

      Compatibility has been ensured for users that contributed a custom jndi session name via a general settings contribution.
      A JndiSMTPMailSender is contributed on the fly at server start and a warning will be given so users can be aware they need to contribute their own MailSender.

      A JndiSMTPMailSender can also be contributed by the users like below but bear in mind this is only a compatibility implementation and we encourage you to leverage another implementation of MailSender instead:

      <?xml version="1.0"?>
      <component name="org.nuxeo.mail.my.sender.contrib">
        <extension target="org.nuxeo.mail.MailServiceComponent" point="senders">
      
          <sender name="mySender" class="org.nuxeo.mail.JndiSMTPMailSender">
            <property name="jndiSessionName">mySessionName</property>
          </sender>
      
        </extension>
      </component>
      
      Show
      Compatibility with custom jndi sessions Compatibility has been ensured for users that contributed a custom jndi session name via a general settings contribution. A JndiSMTPMailSender is contributed on the fly at server start and a warning will be given so users can be aware they need to contribute their own MailSender. A JndiSMTPMailSender can also be contributed by the users like below but bear in mind this is only a compatibility implementation and we encourage you to leverage another implementation of MailSender instead: <?xml version= "1.0" ?> <component name= "org.nuxeo.mail.my.sender.contrib" > <extension target= "org.nuxeo.mail.MailServiceComponent" point= "senders" > <sender name= "mySender" class= "org.nuxeo.mail.JndiSMTPMailSender" > <property name= "jndiSessionName" > mySessionName </property> </sender> </extension> </component>
    • Team:
      PLATFORM
    • Sprint:
      nxplatform #95, nxplatform #96, nxplatform #97, nxplatform #98, nxplatform #99
    • Story Points:
      8

      Description

      Currently, the code to create a javax.mail.internet.MimeMessage and sending it through javax.mail.Transport#send is done in multiple places in the Nuxeo codebase.

      We want to factorize all of this in a single code path. To do that, in the nuxeo-mail module, we want to add:

      • a new MailMessage class that will store everything needed to create the MimeMessage
      • a new MailService + implementation with a method to send a MailMessage
      • the method will juste create a new MimeMessage from the MailMessage and send it through Transport#send.

      Doing that will allow us to easily be able to switch the implementation to send an email in a future next step.

      Acceptance criteria: everything regarding email sending is working as before, no breaking change.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: