Hello,

Thank you for your help.

I have done patch. Please see in attachment.



On Thu, Apr 28, 2016 at 6:17 PM, Ioan Eugen Stan <[email protected]>
wrote:

> Hello,
>
> Usually github is a read only git mirror of Apache repositories. Meaning
> you can't push, especially since you are not a committer.
>
> Read more here [1].
>
> What you should do is either:
>
> 1. work on your clone and create a patch with git patch , submit via email
> 2. fork project on github, push your branch on your fork and issue a
> pull request, then send email to list with PR.
>
> Any branch name is fine.
>
>
> [1] http://www.apache.org/dev/git.html
>
> On 28.04.2016 17:57, Sergey Lysenkov wrote:
> > Hello Antoine,
> >
> > Thank you for your reply.
> > I faced out with problem. I can't push code to repository on
> > https://github.com/apache/james-project
> >
> > I have got error:
> > remote: Permission to apache/james-project.git denied to lysenkovsts.
> > fatal: unable to access 'https://github.com/apache/james-project.git/':
> The
> > requested URL returned error: 403
> >
> > Can you help me to resolve this issue?
> >
> > Also I don't know what branch name will be correct for my code. On my
> local
> > repository I named branch as JAMES-subaddressing. What do you think about
> > that branch name?
> >
> > On Thu, Apr 28, 2016 at 3:57 PM, Antoine DUPRAT <[email protected]>
> > wrote:
> >
> >> Hi,
> >>
> >> Thank you for using James.
> >> We are really happy to receive contribution, you can create a pull
> request
> >> on GitHub:
> >> https://github.com/apache/james-project
> >>
> >> Have a nice day,
> >> Antoine Duprat
> >>
> >>
> >> Hello All,
> >>>
> >>> Our team successfuly used James mail server for a project untile we've
> got
> >>> a requirement to support sub-addressing. It turned out that James does
> not
> >>> support a tag appended to the local part of email address (ex:
> >>> [email protected]). RFC 5233, refers to this convention as
> >>> sub-addressing, but it is also known as plus addressing or tagged
> >>> addressing. To resolve this issue our team have developed
> >>> 'SubAddressingValidRcptHandler' which extends from
> >>> 'org.apache.james.smtpserver.fastfail.ValidRcptHandler' class. Also to
> >>> find
> >>> the right addressee by email address with sub-addressing we have
> developed
> >>> matcher 'SubAddressingMatcher'.
> >>>
> >>> I do not know if you have plans to implement the sub-addressing
> support. I
> >>> can send you our code for review and will be happy if our changes save
> >>> time
> >>> for other developers who faced with the same issue as we had.
> >>>
> >>> Please let me know if that makes sense and which way I can send the
> code
> >>> for review.
> >>>
> >>> Thank you,
> >>> Sergey Lysenkov
> >>>
> >>>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [email protected]
> >> For additional commands, e-mail: [email protected]
> >>
> >>
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
diff --git a/mailet/standard/src/main/java/org/apache/james/transport/matchers/SubAddressingMatcher.java b/mailet/standard/src/main/java/org/apache/james/transport/matchers/SubAddressingMatcher.java
new file mode 100644
index 0000000..7231164
--- /dev/null
+++ b/mailet/standard/src/main/java/org/apache/james/transport/matchers/SubAddressingMatcher.java
@@ -0,0 +1,65 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+package org.apache.james.transport.matchers;
+
+import org.apache.mailet.Mail;
+import org.apache.mailet.MailAddress;
+import org.apache.mailet.MatcherConfig;
+import org.apache.mailet.base.GenericMatcher;
+
+import javax.mail.MessagingException;
+import javax.mail.internet.AddressException;
+import java.util.ArrayList;
+import java.util.Collection;
+
+/**
+ * This Matcher determines if the mail contains sub-addressing, and returns all recipients without sub-addressing part.
+ */
+public class SubAddressingMatcher extends GenericMatcher {
+
+    public void init(MatcherConfig config) throws MessagingException {
+        super.init(config);
+        init();
+    }
+
+    public Collection<MailAddress> match(Mail mail) throws MessagingException {
+        Collection<MailAddress> recipients = mail.getRecipients();
+
+        Collection<MailAddress> tempCollection = new ArrayList<MailAddress>();
+
+        int indexOfPlus;
+        String localPart;
+        for (MailAddress recipient : recipients) {
+            localPart = recipient.getLocalPart();
+            indexOfPlus = localPart.indexOf("+");
+
+            if (indexOfPlus >= 0) {
+                localPart = localPart.substring(0, indexOfPlus);
+            }
+
+            try {
+                tempCollection.add(new MailAddress(localPart, recipient.getDomain()));
+            } catch (AddressException e) {
+                //Do nothing
+            }
+        }
+
+        return tempCollection;
+    }
+}
diff --git a/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/fastfail/SubAddressingValidRcptHandler.java b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/fastfail/SubAddressingValidRcptHandler.java
new file mode 100644
index 0000000..c468468
--- /dev/null
+++ b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/fastfail/SubAddressingValidRcptHandler.java
@@ -0,0 +1,62 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+package org.apache.james.smtpserver.fastfail;
+
+import org.apache.james.protocols.smtp.MailAddress;
+import org.apache.james.protocols.smtp.MailAddressException;
+import org.apache.james.protocols.smtp.SMTPSession;
+
+/**
+ * Handler which reject invalid recipients (support email with subaddressing)
+ */
+public class SubAddressingValidRcptHandler extends ValidRcptHandler {
+
+    /**
+     * Return true if email with sub-addressing for the given recipient should get accepted
+     *
+     * @param session
+     * @param recipient
+     * @return
+     */
+    @Override
+    protected boolean isValidRecipient(SMTPSession session, MailAddress recipient) {
+
+        MailAddress validRecipient = null;
+
+        String localPart = recipient.getLocalPart();
+
+        int indexOfPlus = localPart.indexOf("+");
+
+        if (indexOfPlus > 0) {
+            localPart = localPart.substring(0, indexOfPlus);
+        }
+
+        try {
+            validRecipient = new MailAddress(localPart, recipient.getDomain());
+        } catch (MailAddressException e) {
+            //Do nothing
+        }
+
+        if (validRecipient == null) {
+            validRecipient = recipient;
+        }
+
+        return super.isValidRecipient(session, validRecipient);
+    }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to