Uploaded image for project: 'Seam 2'
  1. Seam 2
  2. JBSEAM-4176

MailSession can't be set to use auth in one environment and not in another


    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.1.1.GA
    • Fix Version/s: None
    • Component/s: Core
    • Labels:


      (Summary could be worded better)

      If you define MailSession in components.xml like this:

      <mail:mail-session host="@mailhost@" port="@mailport@" username="@mailusername@" password="@mailpassword@" />

      And set the mailusername and mailpassword in the environment specific components.properties files, you can't use a mail server without authentication in any environment.

      Putting this in a components.properties:


      seems to set an empty string into the property, which passes the "(getUsername() != null" test in MailSession.java used to determine if it should authenticate with the mail server.

      Therefore it tries to authenticate with empty username and password, which typically fails on a system that doesn't not require auth for outgoing mail (from internal servers for instance).

      In this scenario our dev environment needs to use a mail server that does require auth, but in production, it needs to use a mail server without auth. Currently this is requiring us to manually change the components.xml to have:

      <mail:mail-session host="@mailhost@" port="@mailport@" />

      in the production ear.

      A simple fix would be to change the logic in MailSession to do:

      getUsername() != null && getUsername().trim().length() > 0 instead of the current null check.

      The relevant lines to change are 105, 109, and 152.

        Gliffy Diagrams




              • Assignee:
                modoc Devon Hillard
              • Votes:
                0 Vote for this issue
                1 Start watching this issue


                • Created: