Continuum

mail authentication with username/password doesn't work

Details

  • Type: Bug Bug
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: 1.1, 1.4.2 (Beta)
  • Fix Version/s: None
  • Component/s: Notifier - Mail
  • Labels:
    None
  • Environment:
    Debian 4.0, Tomcat 6.0.14, jdk 1.6.0 u3
  • Complexity:
    Intermediate
  • Number of attachments :
    2

Description

I use continuum as tomcat webapp.

If you use a mailserver with authentication, you can define following in the context.xml of your webapp/META-INF:

<Resource name="mail/Session"
auth="Container"
type="javax.mail.Session"
mail.smtp.auth="true"
mail.smtp.host="mailserver"
mail.smtp.port="25"
mail.smtp.user="username"
password="password"/>

The problem is, that the parameter password will be ignored. I found the problem in:

org.codehaus.plexus.mailsender.javamail.JndiJavamailMailSender.getSession

->

Context ctx = new InitialContext();
Session s = (Session)ctx.lookup(jndiSessionName);

The session doesn't contain a property called "password".

My dirty workaround to solve the problem:

renamed password to mail.smtp.password (in context.xml) and wrote a class which extends JndiJavamailMailSender with overriden getSession:

public Session getSession() throws MailSenderException

{ Session sess = super.getSession(); Properties prop = sess.getProperties(); prop.setProperty(JndiJavamailMailSender.MAIL_SMTP_PASSWORD, prop.getProperty("mail.smtp.password")); return Session.getInstance(prop, null); }

Maybe you set the value of the constant MAIL_SMTP_PASSWORD to "mail.stmp.password" and everything is fine!

  1. plex-javamail.patch
    08/May/08 9:51 AM
    0.5 kB
    Victor Suarez
  2. plex-javamail-2.patch
    08/May/08 10:05 AM
    0.8 kB
    Victor Suarez

Activity

Hide
Olivier Lamy added a comment -

can you attach a patch ?

Show
Olivier Lamy added a comment - can you attach a patch ?
Hide
Victor Suarez added a comment -

Why does the code do "return Session.getInstance( props, null );"? Why not just "return s;"? Do we need another Session object?

Show
Victor Suarez added a comment - Why does the code do "return Session.getInstance( props, null );"? Why not just "return s;"? Do we need another Session object?
Hide
Victor Suarez added a comment -

With this changes SMTP authentication is working for me. Session.getInstance(props, null) creates a new session but without Authenticator.

Show
Victor Suarez added a comment - With this changes SMTP authentication is working for me. Session.getInstance(props, null) creates a new session but without Authenticator.
Hide
Victor Suarez added a comment -

Second attachment supersedes first one. In the plex-javamail-2.patch I removed the copy of session properties.

Show
Victor Suarez added a comment - Second attachment supersedes first one. In the plex-javamail-2.patch I removed the copy of session properties.
Hide
René jahn added a comment -

Sorry, for my very late answer... had no internet connection last months

First:

I wrote a dirty fix in my own class. It's also possible to return s, no problem.

How did you set the passwort into the session object? Did you rename the property?

Show
René jahn added a comment - Sorry, for my very late answer... had no internet connection last months First: I wrote a dirty fix in my own class. It's also possible to return s, no problem. How did you set the passwort into the session object? Did you rename the property?
Hide
Victor Suarez added a comment -

Sorry, for my very late answer... had no internet connection last months

Don't worry, I didn't ask about your code, I did ask about the original sources. You resolved the problem, but original source uses the JNDI resource in a way that I can't understand.

How did you set the password into the session object? Did you rename the property?

With the "password" attribute, like you. When you put a resource in context.xml, Tomcat (or any web container) is responsible for connecting and manage the sessions. Because of that you use the Tomcat mail session directly, and Session.getInstance is not needed (or you will lose the authenticator that was associated by Tomcat).

Indeed, I think that AbstractJavamailMailSender.send() does many redundant work already done by Tomcat (IMHO).

Regards,
Victor

Show
Victor Suarez added a comment -
Sorry, for my very late answer... had no internet connection last months
Don't worry, I didn't ask about your code, I did ask about the original sources. You resolved the problem, but original source uses the JNDI resource in a way that I can't understand.
How did you set the password into the session object? Did you rename the property?
With the "password" attribute, like you. When you put a resource in context.xml, Tomcat (or any web container) is responsible for connecting and manage the sessions. Because of that you use the Tomcat mail session directly, and Session.getInstance is not needed (or you will lose the authenticator that was associated by Tomcat). Indeed, I think that AbstractJavamailMailSender.send() does many redundant work already done by Tomcat (IMHO). Regards, Victor

People

Vote (1)
Watch (3)

Dates

  • Created:
    Updated: