Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

HTML Wrap
alignright
classmenu

Related:

The Mail module enables the sending of emails from within Magnolia. The module can be used to send plain text and HTML messages, and template-based messages.

...

The Mail module is configured at Configuration > /modules/mail. Besides configuring SMTP settings the module is ready to use.

...

MailCommand is used to send all mails in Magnolia. The command can execute on events such as user actions, workflow steps and scheduled jobs. You can write message templates and test them manually in the Mail tools app before automating the process for production use.

...

  • SMTP server: Name of your mail server.
  • Authentication: Select:
    • Authentication with username and password,
      • Username: SMTP user name.
      • Password: SMTP user's password.
    • No authentication required.
  • Security:
    • No encryption for simple SMTP (default communication port is 25).
    • SMTP over SLL (SMTPS, SSL v3) (port 465).
    • (port 587).
  • Port: Dependent on security setting.

...

  1. Verify the current setup.
  2. Verify message templates.

Use the first tool to send test mails to verify your SMTP settings. The tool sends a pre-configured simple mail with an optional attachment to the email address in the logged in user's profile.

...

The second tool in the Verify setup subapp allows you to verify your mail message templates. Message templates are typically used by forms on pages to send the data to the user who submitted the form.

As in the case of verifying mail settings, the tool sends the test mail to the email address configured in your user profile.

...

  • Select a template in the dropdown. Only registered templates are available. See Templates configuration for more information.
  • Enter the test data. The content depends on the template configuration.
  • Click Send Test Mail.

...

  • Properties:
    • templateFile: Mandatory. Relative path to the template script. 
    • type: Mandatory. Scripting language used in the template.
    • contentType: Type of content for the message body. It is only necessary to include this property for HTML emails.
    • from: Email address that will appear in the From field of the message, unless defined elsewhere, for example in Form module.
      subject: Subject line of the email, unless defined elsewhere for example in the Form module.
  • Nodes:
    • attachments: MailAttachment provides for a number of attachment options. 
    • parameters: Any parameters to be passed to the script.

      Advanced Tables - Table Plus
      enableHeadingAttributesfalse
      enableSortingfalse
      classm5-configuration-tree
      enableHighlightingfalse


      Node nameValue

      Mgnl f
      config

       

      Mgnl f
      templatesConfiguration

       

      Mgnl n
      testFreemarker

       

      Mgnl n
      attachments

       

      Mgnl n
      parameters

       

      Mgnl p
      contentType

      html

      Mgnl p
      from

      testfreemarker@example.com

      Mgnl p
      subject

       This is a test email for freemarker template

      Mgnl p
      templateFile

       testFreemarker.html

      Mgnl p
      type

      freemarker

      Mgnl n
      pageCommentsNotification

       



...

This script requires two parameters, user and path, that need to be provided in the Data to send box in the verify templates tool. The parameters are passed to the template script and rendered in the message. Each parameter should be added on a single line in the <parameter name=<value> format. For example:

...

  1. Create a template named, for example simpleTemplate.html using Freemarker code.

    Code Block
    <html>
      <body>
        <p>Dear ${fullName},</p>
        <p>Please follow this link in order to validate your account: 
        <a href="${href}">Verify your user</a></p>
        <p>Thank you!</p>
      </body>
    </html>


  2. Save the template to the file system in for example, /<CATALINA_HOME>/webapps/<contextPath>/templates/simpleTemplate.html. You can put the template anywhere in the webapps folder of a Magnolia instance. 
  3. Register the new template in the /config/templatesConfiguration node.

    Advanced Tables - Table Plus
    enableHeadingAttributesfalse
    enableSortingfalse
    classm5-configuration-tree
    enableHighlightingfalse


    Node nameValue

    Mgnl f
    config

     

    Mgnl f
    templatesConfiguration

     

    Mgnl n
    newUserRegistration

     

    Mgnl n
    attachments

     

    Mgnl n
    parameters

     

    Mgnl p
    contentType

    html

    Mgnl p
    from

    info@registrations.com

    Mgnl p
    subject

    New User Registration

    Mgnl p
    templateFile

    templates/simpleTemplate.html

    Mgnl p
    type

    freemarker



  4. The new template appears in the dropdown list in the Verify templates tool.
Info

Email applications and clients on the market display emails in different ways. The main reason for this is varied support for CSS styles. You can use a web based service such as Mailchimp Inbox Inspector to preview the message in various clients and work towards consistency.

...