You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-user@james.apache.org by Dave Havard <da...@capital-connection.net> on 2004/04/25 14:19:15 UTC

Authentication

Hi

I am having a problem getting James working with JavaMail and
authentication. I am running James 2.1.3 on XPPro and using Resin as my
servlet engine. I have a mail session defined in resin.conf as:

<resource jndi-name="mail/Session" type="javax.mail.Session">
    <init>
        <mail.transport.protocol>smtp</mail.transport.protocol>
        <mail.store.protocol>pop3</mail.store.protocol>
        <mail.host>localhost</mail.host>
        <mail.smtp.auth>true</mail.smtp.auth>
    </init>
</resource>

I then have a MailClient class defined as follows:

import com.dh.app.Application;
import java.io.*;
import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.naming.*;

public class MailClient extends Authenticator {

 private Context _ctx=null;
 private User _user=null;
 private Session _session=null;
 private PasswordAuthentication _authentication=null;

 public MailClient(User user) throws NamingException {
            _user=user;
            _authentication=new PasswordAuthentication(_user.getUsername(),
_user.getPassword());
            _ctx=new InitialContext();
            _session=(Session) _ctx.lookup(Application.getJNDISMTPPath());
 }

 public PasswordAuthentication getPasswordAuthentication() {
      return _authentication;
 }

 public void send(String from, String to, String subject, String content)
throws MessagingException {
             // Prepare mail message
             Message message=new MimeMessage(_session);
             message.setFrom(new InternetAddress(from));
             InternetAddress dests[]=new InternetAddress[] { new
InternetAddress(to) };
             message.setRecipients(Message.RecipientType.TO, dests);
             message.setSubject(subject);
             message.setContent(content, "text/plain");
             // Send mail message
             Transport.send(message);
 }

}

the User.getUsername() and User.getPassword() return the unencrypted text
for each of these values however when I try to send I get the following
exception:

javax.mail.SendFailedException: Sending failed;
  nested exception is:
	class javax.mail.AuthenticationFailedException


Any ideas what I am missing??

Thanks in advance!

Dave


---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


RE: reprocessing messages

Posted by "Noel J. Bergman" <no...@devtech.com>.
> My reading of the response is that unless I move to 2.2.0RC2,  I can't
> really use the FromRepository or MailAttribute

Correct, although you could back-port FromRepository if necessary.

> James is deployed as part of the ASP service that we provide and
> I am a bit timid about putting Release Candidates in production.

Well, considering that you are at a testing stage, and James 2.2.0 should be
released this week ... :-)

Besides, if there are any showstoppers, you would want to let us know ASAP.
So far the only reported problem is that PostgreSQL has a deficient JDBC
driver.

	--- Noel


---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


Re: reprocessing messages

Posted by Shal Jain <sh...@intertechsys.com>.
Appreciate the quick response.

My reading of the response is that unless I move to 2.2.0RC2,  I can't
really use the FromRepository or MailAttribute

I have been using AddHeaders and then manually checking the msgs in
the outbound queue but the header is not showing up in the msg.  I'll
reverify
what I am doing. (That was the initial intent w/a mailet configured in the
outbound
queue).  Forgot about DEBUG though. Thanx.

James is deployed as part of the ASP service that we provide and
I am a bit timid about putting Release Candidates in production.



----- Original Message -----
From: "Noel J. Bergman" <no...@devtech.com>
To: "James Users List" <se...@james.apache.org>
Sent: Sunday, April 25, 2004 3:57 PM
Subject: RE: reprocessing messages


> > James - 2.1.2
>
> You really should update.
>
> > is it possible to modify the message by attaching a
> > known extension field to it.
>
> If you were running 2.2.0RC2, you could use a Mail Attribute, which does
not
> effect the message content at all.  In 2.1.2, you could use AddHeader and
> check for the presence of the header.
>
> > James doesn't seem to send the msg back to the inbound queue
> > even though the domains understood by James are part of the
> > message (how the message originally came to James)
>
> Always turn on DEBUG for the spool manager if you are having issues in how
> messages are directed through the pipeline.
>
> > What I would really like to do is file the messages under a known
> > JAMES user e.g. 'UNFILED' and then reprocess them using another
> > mailet thus avoiding the outbound queue completely.
>
> See FromRepository in James 2.2.0RC2.
>
> --- Noel
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
> For additional commands, e-mail: server-user-help@james.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


RE: reprocessing messages

Posted by "Noel J. Bergman" <no...@devtech.com>.
> James - 2.1.2

You really should update.

> is it possible to modify the message by attaching a
> known extension field to it.

If you were running 2.2.0RC2, you could use a Mail Attribute, which does not
effect the message content at all.  In 2.1.2, you could use AddHeader and
check for the presence of the header.

> James doesn't seem to send the msg back to the inbound queue
> even though the domains understood by James are part of the
> message (how the message originally came to James)

Always turn on DEBUG for the spool manager if you are having issues in how
messages are directed through the pipeline.

> What I would really like to do is file the messages under a known
> JAMES user e.g. 'UNFILED' and then reprocess them using another
> mailet thus avoiding the outbound queue completely.

See FromRepository in James 2.2.0RC2.

	--- Noel


---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


Re: reprocessing messages

Posted by Shal Jain <sh...@intertechsys.com>.
OS - Win2K
James - 2.1.2


I have a mailet configured as part of the inbound email processor which
handles all incoming messages -
the messages are either ghosted (successful handled) or bounced back to the
sender (unsuccessful handling).  No user accounts
are defined in JAMES.
The message handling is done by another process accessible through a
webservice.
If the webservice is not available, the message doesn't get handled and
falls
through and gets put into the outbound queue for a redelivery attempt.

James doesn't seem to send the msg back to the inbound queue
even though the domains understood by James are part of the message (how the
message originally came to James)

Upon availability of the webservice, I'd like to process the messages that
initially couldn't be handled.
So before passing on the message through, is it possible to modify the
message by attaching a known extension field to it. My initial attempts
to do so are failing.
Barring that approach,
what's the best way to distinguish between these initially inbound message
vs. messages that are being truly being sent out.

What I would really like to do is file the messages under a known JAMES user
e.g. 'UNFILED' and then reprocess them using another mailet
thus avoiding the outbound queue completely.   Do I have to essentially
write a 'pop3' client to fetch mails from this special useraccount ?

Any advice is appreciated

-shal









---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


RE: Authentication

Posted by "Noel J. Bergman" <no...@devtech.com>.
> I am getting the following error:
> SendFailedException: Sending failed;
>...
> 	UnsupportedDataTypeException: no object DCH for MIME type text/plain;

Is that with your application or James?  I'm assuming the former, in which
case it doesn't matter what is in james.sar.

> Apparently a webapps many not be able to access mailcap files in
> both the mail and jaf jars so I placed a copy of both of these
> files into the META-INF folder of my app but no change.

You might want to subscribe to the JavaMail Interest list.  And you may be
running into something Resin specific.

	--- Noel


---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


Re: Authentication

Posted by Dave Havard <da...@capital-connection.net>.
Thanks Noel - I'll leave it as it is for now as I have hit another
problem...

I am getting the following error:

javax.mail.SendFailedException: Sending failed;
  nested exception is:
	class javax.mail.MessagingException: IOException while sending message;
  nested exception is:
	javax.activation.UnsupportedDataTypeException: no object DCH for MIME type
text/plain; charset=us-ascii

I have searched round the net for a couple of hours now and there seem to be
a few possible reasons for this. I have tried the following without sucess:

1. Remove any duplcate mail and jaf jars. I have done this but there is one
of each in James.sar. Although I cannot remove these I removed all the
others and replaced them with the ones used by James. There was no change so
I switched everything back.
2. From one of Noels solutions, I re-downloaded James, JavaMail and JAF in
case they had become corrupt. Reinstalled them all but no change.
3. Apparently a webapps many not be able to access mailcap files in both the
mail and jaf jars so I placed a copy of both of these files into the
META-INF folder of my app but no change.

Does anybody have any other ideas?

Thanks
Dave

----- Original Message ----- 
From: "Noel J. Bergman" <no...@devtech.com>
To: "James Users List" <se...@james.apache.org>
Sent: Sunday, April 25, 2004 8:49 PM
Subject: RE: Authentication


> > I am no doubt being blind but can anyone explain how I register an
> > Authenticator with a Session returned from JNDI?
>
> I don't know of any way to set a session's authenticator after the session
> has been instantiated, but you could call setPasswordAuthentication.
>
> --- Noel
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
> For additional commands, e-mail: server-user-help@james.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


RE: Authentication

Posted by "Noel J. Bergman" <no...@devtech.com>.
> I am no doubt being blind but can anyone explain how I register an
> Authenticator with a Session returned from JNDI?

I don't know of any way to set a session's authenticator after the session
has been instantiated, but you could call setPasswordAuthentication.

	--- Noel


---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


Re: Authentication

Posted by Dave Havard <da...@capital-connection.net>.
Hi Noel

Your second point has solved it - thank you! I am no doubt being blind but
can anyone explain how I register an Authenticator with a Session returned
from JNDI? The only way I can see is to create another Session from the one
returned, passing the same Properties and the Authenticator. Whereas this
works it seems somewhat inelegent... Anyone know of an alternative please?

Thanks
Dave


----- Original Message ----- 
From: "Noel J. Bergman" <no...@devtech.com>
To: "James Users List" <se...@james.apache.org>
Sent: Sunday, April 25, 2004 5:19 PM
Subject: RE: Authentication


> I don't know if it applies in your case, not having looked too closely at
> your code, but PLAIN AUTH was broken until recently.  Please try 2.2.0RC2
> instead of 2.1.3.
>
> On another note, where are you registering the Authenticator with the
> Session?  I'm looking at org.apache.naming.factory.MailSession, and it
> calls:
>
>   Session session = Session.getInstance(props, null);
>   return (session);
>
> which means that there is no Authenticator registered with that Session as
> it comes back from the JNDI ObjectFactory.
>
> --- Noel
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
> For additional commands, e-mail: server-user-help@james.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


RE: Authentication

Posted by "Noel J. Bergman" <no...@devtech.com>.
I don't know if it applies in your case, not having looked too closely at
your code, but PLAIN AUTH was broken until recently.  Please try 2.2.0RC2
instead of 2.1.3.

On another note, where are you registering the Authenticator with the
Session?  I'm looking at org.apache.naming.factory.MailSession, and it
calls:

  Session session = Session.getInstance(props, null);
  return (session);

which means that there is no Authenticator registered with that Session as
it comes back from the JNDI ObjectFactory.

	--- Noel


---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org