Hi Hen,

many thanks for your answer.
Here is a long mail on commons-email status :)

SVN Repository
The activity on SVN repository (speaking of the src/java dir) is stalled about 
5 month ago. What you can find in SVN repository compiles fine and looks like 
what has been released as 'Commons Email 1.0' on 2005-09-27.

Bugs
As you can see in [1] there are 11 bug open
[37344] This bug provide a patch (in reality it provides a whole new class). 
I'm using this provided class with my patched version of commons-email and it 
is working fine without any issue so far.
[37178] Can be resolved using the new class provided in previous bug.
[38538] This is fixed in my own attached patch.
[37902] Trivial ;)
[37783] Includes a patch. I'm using this provided patch with my patched 
version of commons-email and it is working fine without any issue so far.
[37782] Includes a patch which forces a new dependency on javax.naming.* I'm 
using this provided patch with my patched version of commons-email and it is 
working fine without any issue so far.
[36856] Includes patches I cannot test and I do not need
[36844] Includes patches I did not test
[37363] Don't have a clue on this one.

Patch
Attached you can find a SVN patch that fixes many problems you can see if 
using a MailSession that needs authentication. It includes also the patch 
from bug [37782]. I'm using this provided patch with my patched version of 
commons-email and it is working fine without any issue so far.

Todo
As you can see in my attached patch and in reported bugs there are many 
"simple" bug that need fixing non tonly in SVN but also as a new 1.0.1 (maybe 
1.1) release of commons-email.

Hope this helps ;)

Bye
Piero


[1]http://issues.apache.org/bugzilla/buglist.cgi?bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&email1=&emailtype1=substring&emailassigned_to1=1&email2=&emailtype2=substring&emailreporter2=1&bugidtype=include&bug_id=&changedin=&votes=&chfieldfrom=&chfieldto=Now&chfieldvalue=&product=Commons&component=Email&short_desc=&short_desc_type=allwordssubstr&long_desc=&long_desc_type=allwordssubstr&bug_file_loc=&bug_file_loc_type=allwordssubstr&keywords=&keywords_type=anywords&field0-0-0=noop&type0-0-0=noop&value0-0-0=&cmdtype=doit&newqueryname=&order=Reuse+same+sort+as+last+time


Alle 22:05, mercoledì 8 febbraio 2006, Henri Yandell ha scritto:
> On 2/8/06, Piero Ottuzzi <[EMAIL PROTECTED]> wrote:
> > Hi Chris,
> >
> > I already read URLs you proposed and they simply say to open a bug or
> > send a patch; in commons-mail bugzilla you can find about 10 open bugs
> > many of them with patch attached. If you look at SVN commons-mail
> > repository you can't see any commit in source code in the last 5 month; I
> > think the problem is not to post a bug or a patch (both things already
> > done) but to apply these patches to SVN repository.
>
> Well, the problem is to review those patches and then commit. Then
> once committed, to plan a release and get something out. We're very
> noticeably becoming slowly overwhelmed by the component to
> active-committer count in Commons, so finding ways to keep juggling
> all these things is critical.
>
> My suggestion; write up a summary of the issues for the list. Let's
> say I had a free few hours tomorrow and wanted to get [email] moving.
> I'd take a look at the issues in [email]; possibly do an svn log on
> the codebase to see if I can judge how much change there has been
> since the last release; I'd check the code out of svn and make sure it
> compiles for me. Then I'd write up an email explaining any problems
> with compiling, discussing the features in svn waiting to be released
> and listing each bug with commentary on each.
>
> Probably all of that before I actually applied any bugs or any fixes.
> Then I'd either
>
> a) apply patches that I think sound good from bugzilla to my local
> source and prove that they compile. I'd double check the tests
> involved to make sure the test is testing the patch. Usual TDD bit
> here, write a test to fail, then apply patch - feel warm and cozy when
> it works.
>
> b) start fixing bugs without patches - and submit them to bugzilla
> with tests etc. I'd then send an email to the list, possibly as a
> reply to my first email, saying that I've fixed bug N.
>
> It's only when it came time to commit a) or b) that I'd actually need
> to be a committer. So don't let that hold you back.
>
> > If it would be possible I would like to step as committer for the
> > common-mail repository at least to do some house-keeping. I hope I was
> > not too harsh or ambitious.
>
> Nope, not too harsh or ambititous at all. We really want to turn users
> into committers, it's a pretty cool thing to watch someone getting
> more and more into the community and committing things.
>
> 'Committer' is a good word for explaining why we don't leap on offers
> - we need to see commitment. The reality is that there is very little
> that you actually need svn access for; you can drive things without
> being a committer and if you start driving things - a vote on
> committership will probably follow a little after it's needed. Such is
> life :)
>
> Hen
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]

-- 
GPG KeyID: 84AE988E
Fingerprint: F0A0 CA2A 8D8F CC12 3F5E  C04C D8D5 9DC3 84AE 988E
gpg --keyserver x-hkp://search.keyserver.net:11371 --recv-key 84AE988E
Index: src/java/org/apache/commons/mail/Email.java
===================================================================
--- src/java/org/apache/commons/mail/Email.java (revision 375602)
+++ src/java/org/apache/commons/mail/Email.java (working copy)
@@ -24,6 +24,10 @@
 import java.util.Map;
 import java.util.Properties;
 
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
 import javax.mail.Authenticator;
 import javax.mail.Message;
 import javax.mail.MessagingException;
@@ -73,7 +77,7 @@
     public static final String CONTENT_TYPE = "content.type";
 
     /** */
-    public static final String MAIL_HOST = "mail.host";
+    public static final String MAIL_HOST = "mail.smtp.host";
     /** */
     public static final String MAIL_PORT = "mail.smtp.port";
     /** */
@@ -81,9 +85,15 @@
     /** */
     public static final String MAIL_SMTP_AUTH = "mail.smtp.auth";
     /** */
+    public static final String MAIL_SMTP_USER = "mail.smtp.user";
+    /** */
+    public static final String MAIL_SMTP_PASSWORD = "mail.smtp.password";
+    /** */
     public static final String MAIL_TRANSPORT_PROTOCOL =
         "mail.transport.protocol";
     /** */
+    public static final String MAIL_TRANSPORT_TLS = "mail.smtp.starttls.enable";
+    /** */
     public static final String SMTP = "smtp";
     /** */
     public static final String TEXT_HTML = "text/html";
@@ -191,6 +201,9 @@
     /** The Session to mail with */
     private Session session;
 
+    /** does server require TLS encryption for authentication */
+    protected boolean tls = false;
+    
     /**
      * Setting to true will enable the display of debug information.
      *
@@ -314,6 +327,16 @@
     }
 
     /**
+     * Set or disable the TLS encryption 
+     *
+     * @param   withTLS true if TLS needed, false otherwise
+     */
+    public void setTLS(boolean withTLS)
+    {
+        this.tls = withTLS;
+    }
+
+    /**
      * Set the port number of the outgoing mail server.
      * @param   aPortNumber aPortNumber
      * @since 1.0
@@ -338,10 +361,48 @@
      */
     public void setMailSession(Session aSession)
     {
-        this.session = aSession;
+        Properties sessionProperties = aSession.getProperties();
+        String auth = sessionProperties.getProperty(MAIL_SMTP_AUTH);
+        if ("true".equalsIgnoreCase(auth))
+        {
+            String userName = sessionProperties.getProperty(MAIL_SMTP_USER);
+            String password = sessionProperties.getProperty(MAIL_SMTP_PASSWORD);
+            this.authenticator = new DefaultAuthenticator(userName, password);
+            this.session = Session.getInstance(sessionProperties, this.authenticator);
+        }
+        else
+        {
+            this.session = aSession;
+        }
     }
 
     /**
+     * Supply a mail Session object from a JNDI directory
+     * @param jndiName name of JNDI ressource (javax.mail.Session type), ressource
+     * if searched in java:comp/env if name dont start with "java:"
+     * @throws IllegalArgumentException JNDI name null or empty
+     * @throws NamingException ressource can be retrieved from JNDI directory
+     */
+    public void setMailSessionFromJNDI(String jndiName) throws NamingException
+    {
+        if(EmailUtils.isEmpty(jndiName))
+        {
+            throw new IllegalArgumentException("JNDI name missing");
+        }
+        Context ctx = null;
+        if(jndiName.startsWith("java:"))
+        {
+            ctx = (Context) new InitialContext();
+        }
+        else
+        {
+            ctx = (Context) new InitialContext().lookup("java:comp/env");
+
+        }
+        setMailSession((Session) ctx.lookup(jndiName));
+    }
+
+    /**
      * Initialise a mailsession object
      *
      * @return A Session.
@@ -372,6 +433,7 @@
 
             if (this.authenticator != null)
             {
+                properties.setProperty(MAIL_TRANSPORT_TLS, Boolean.toString(tls));
                 properties.setProperty(MAIL_SMTP_AUTH, "true");
             }
 
@@ -783,7 +845,10 @@
             }
             else
             {
-                throw new EmailException("Sender address required");
+                if(session.getProperty(MAIL_SMTP_FROM) == null)
+                {
+                    throw new EmailException("Sender address required");
+                }
             }
 
             if (this.toList.size() + this.ccList.size() + this.bccList.size() == 0)
@@ -952,7 +1017,14 @@
      */
     public String getHostName()
     {
-        return this.hostName;
+        if (EmailUtils.isNotEmpty(this.hostName))
+        {
+            return this.hostName;
+        }
+        else
+        {
+            return this.session.getProperty(MAIL_HOST);
+        }
     }
 
     /**
@@ -962,10 +1034,27 @@
      */
     public String getSmtpPort()
     {
-        return this.smtpPort;
+        if (EmailUtils.isNotEmpty(this.smtpPort))
+        {
+            return this.smtpPort;
+        }
+        else
+        {
+            return this.session.getProperty(MAIL_PORT);
+        }
     }
 
     /**
+     * Gets encryption mode for authentication
+     *
+     * @return true if using TLS for authentication, false otherwise
+     */
+    public boolean isTLS()
+    {
+        return this.tls;
+    }
+
+    /**
      * Utility to copy List of known InternetAddress objects into an
      * array.
      *

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to