Hello Robert,

please keep in mind for "mulithomed" servers, or servers with more than one 
network card.
So I have some remarks:

Remarks to "mail.smtp.localhost":
------------------------------------------
As I could remember, the "mail.smtp.localhost" and other properties are defined 
by SUN.
https://javamail.java.net/nonav/docs/api/com/sun/mail/smtp/package-summary.html
So they are implemented by the "mail.jar" or "smpt.jar" implementation (the 
javax.mail packages).
This mail.jar API is rather old, and seems not be active developed. Btw. it is 
from SUN, so it is may be "history".

We are using james 2.3.2 in production, and we discovered some parsing errors 
inside mail.jar.
E.g. If the mail is some kind of non-standard format (like filename=xyz.pdf, 
with missing quotes), the jar has parsing problems.
This happens mostly by spam mails, so it may be ignored. But there seems to be 
nobody to fix this at Oracle.
So I am not sure if Geronimo implements these parameters, or should implement 
this parameters.
But, on the other side, it is defined and could be used as default.

These smtp parameters could be set on startup as java vm parameters, and will 
be interpreted by the mail.jar.
So it worked in james 2.3.2, but this seems not to be comfortable. So 
configuration should be possible.

The problem with these parameters is, that it may be difficult to set addresses 
for hosts with more than one network card.
If you have a host, which listens to two hostnames, to which value would you 
set the hostname?
So it may always be a default implementation, which should be possible to 
configure.

Remarks to getLocalHost():
---------------------------------
Also the call to InetAddress.getLocalHost() is not clear for hosts listening on 
two network cards.
Some implementations seem to deliver always "127.0.0.1" as localhost. So this 
call does sometimes offer the address of a "loopback" adapter. I think this 
depends on the OS/Linux system used.
In my opinion, this is not a bug, because it is not clear which network card to 
use on getLocalHost().
But the same: it should be an option for default implementation, which should 
always be possible to configure.

Just my remarks.

Many thanks for fixing that.



Thanks,
Bernd

-----Ursprüngliche Nachricht-----
Von: Robert Munn [mailto:[email protected]] 
Gesendet: Dienstag, 28. Oktober 2014 09:29
An: James Users List
Betreff: Re: James 3 b4 HELO Override Not Working?

Last followup about this subject for now. I did some digging into Geronimo 
Javamail. There is a newer version, but the implementation has not changed, and 
I don't think it is regarded as a bug. I don't see in the docs where 
mail.smtp.localhost is supposed to preempt the 
InetAddress.getLocalHost().getHostName() method call. Jerry, if you could point 
me in the right direction that would be great.

I also did some digging about InetAddress.getLocalHost().getHostName()  and 
found no clear answer that it is the "accepted" way to get the hostname, for 
exactly the reason that we have encountered - too many ways for the 
configuration (DNS, etc.) to foul up the works. There is also a discussion that 
has me thinking getCanonicalHostName() should be the method called because it 
will try to get the FQDN, where getHostName() is clearly just grabbing the 
local server name. 

http://stackoverflow.com/questions/7348711/recommended-way-to-get-hostname-in-java/7800008#7800008

http://stackoverflow.com/questions/12669076/host-name-vs-canonical-host-name

I agree with you that MailConnection.java should check for 
"mail.smtp.localhost" in properties first, but it looks like the property being 
used in Geronimo is "localhost", so I don't know whether it is worth pursing a 
fix at this time. I may run it by the Geronimo mailing list to see if anyone 
has run into this issue.






On Oct 27, 2014, at 7:50 PM, Robert Munn <[email protected]> wrote:

> A couple of additional notes. This issue appeared on Ubuntu as well, 
> so it is not just a windows issue.
> 
> On the  good side, the version of Geronimo java mail in the app is 
> fairly old, so this bug may be fixed already.
> On Oct 27, 2014 12:29 PM, "Jerry Malcolm" <[email protected]> wrote:
> 
>> Well, Robert, you get the prize.... It works (finally)!
>> 
>> Two changes required to RemoteDelivery mailet:
>> 
>> Add:
>> import org.apache.geronimo.javamail.transport.smtp.*;
>> 
>> Right after:
>>    transport = session.getTransport(outgoingMailServer);
>> 
>> add:
>> ((org.apache.geronimo.javamail.transport.smtp.SMTPTransport)transport
>> ).setLocalHost(
>> "mail.jwmhosting.com");
>> 
>> or be more generic and get the value from props.
>> 
>> The setLocalHost needs to be right after the object is instantiated 
>> since the HELO is sent on one of the first calls to transport.
>> 
>> This fixes it (thank you so much for your help).  But Geronimo is 
>> still not following the spec and honoring the property 
>> mail.smtp.localhost.  It needs to be fixed in a subsequent release.
>> 
>> Basically everybody using James 3 needs to add this fix to the 
>> mailet, at least if running on a Windows server.  Or verify through 
>> mail-tester.com that the HELO is correct.  Going back to the orig 
>> problem, gmail was not delivering tons of my mail due to this.
>> 
>> Thanks again.
>> 
>> Now.... anybody offer any help on getting jDKIM working?  I've got it 
>> implemented and the DNS is set up.  But mail-tester is telling me the 
>> signature is invalid.  On to the next problem.....
>> 
>> Jerry
>> 
>> 
>> 
>> 
>> On 10/27/2014 2:00 PM, Jerry Malcolm wrote:
>> 
>>> The mailet only sees 'transport' which is cast to generic
>>> "javax.mail.Transport".   The localhost methods and connection methods are
>>> all part of the geronimo impl.  You'll need to cast the transport to 
>>> the geronimo package for the class, then see if you can get the 
>>> connection object from the transport.  Might work.  But non-trivial.  
>>> I'll play around with that was well.
>>> 
>>> Jerry
>>> 
>>> On 10/27/2014 1:41 PM, Robert Munn wrote:
>>> 
>>>> Here is the base code. Note localHost is a property of the 
>>>> MailConnection class. Note also that there is a setLocalHost() 
>>>> method. I am going to try setting the localhost property from 
>>>> RemoteDelivery using setLocalHost( localHost ).
>>>> 
>>>>     public String getLocalHost() throws MessagingException {
>>>>         if (localHost == null) {
>>>> 
>>>>             try {
>>>>                 localHost = InetAddress.getLocalHost().getHostName();
>>>>             } catch (UnknownHostException e) {
>>>>                 // fine, we're misconfigured - ignore
>>>>             }
>>>> 
>>>>             if (localHost == null) {
>>>>                 localHost = props.getProperty(MAIL_LOCALHOST);
>>>>             }
>>>> 
>>>>             if (localHost == null) {
>>>>                 localHost = props.getSessionProperty(MAIL_LOCALHOST);
>>>>             }
>>>> 
>>>>             if (localHost == null) {
>>>>                 throw new MessagingException("Can't get local hostname.
>>>> "
>>>>                         + " Please correctly configure JDK/DNS or 
>>>> set mail.smtp.localhost");
>>>>             }
>>>>         }
>>>> 
>>>>         return localHost;
>>>>     }
>>>> 
>>>>          /**
>>>>      * Explicitly set the local host information.
>>>>      *
>>>>      * @param localHost
>>>>      *            The new localHost name.
>>>>      */
>>>>     public void setLocalHost(String localHost) {
>>>>         this.localHost = localHost;
>>>>     }
>>>> 
>>>> 
>>>> 
>>>> 
>>>> On Oct 27, 2014, at 11:28 AM, Jerry Malcolm 
>>>> <[email protected]>
>>>> wrote:
>>>> 
>>>> mailet calls 'transport' which is an "SMTPTransport" instance.
>>>>> SMTPTransport calls SMTPConnection.getLocalHost() which is 
>>>>> inherited from MailConnection.getLocalHost().
>>>>> 
>>>>> That method returns the InetAddress().getLocalHost().getHostName()
>>>>> first.  According to the spec, that should only occur IF the 
>>>>> property mail.smtp.localhost is not set.  So i think the fix 
>>>>> should be in that method.
>>>>> 
>>>>> The very first thing in the MailConnection.getLocalHost() method 
>>>>> should be something like:
>>>>> ---------------------------------------
>>>>> if ( props.getProperty( "mail.smtp.localhost" ) != null ) return( 
>>>>> props.getProperty( "mail.smtp.localhost" ));
>>>>> ---------------------------------------
>>>>> Then let it try all of the other options if and only if this 
>>>>> property is NOT set.
>>>>> 
>>>>> Jerry
>>>>> 
>>>>> On 10/27/2014 1:07 PM, Robert Munn wrote:
>>>>> 
>>>>>> More info. SMPTConnection.java extends MailConnection.java which 
>>>>>> has a method with this signature:
>>>>>> 
>>>>>>   public boolean protocolConnect(String host, int port, String 
>>>>>> username, String password) throws MessagingException
>>>>>> 
>>>>>> If you fail to pass 'host' as an argument to the method, the host 
>>>>>> defaults to 'localhost'. A patch could be made there. A better 
>>>>>> patch would be to find the upstream code that is calling this 
>>>>>> method and patch it to send the correct hostname. I am hunting 
>>>>>> for that location, please let me know if you have any suggestions...
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> On Oct 27, 2014, at 10:25 AM, Jerry Malcolm 
>>>>>> <[email protected]>
>>>>>> wrote:
>>>>>> 
>>>>>> Thanks for jumping in and investigating.  This has gone from ugly 
>>>>>> to
>>>>>>> horrible....  I think I have found the culprit.
>>>>>>> 
>>>>>>> I first had to figure out who is providing the class for
>>>>>>> SMTPTransport.   figured out that the package for SMTPTransport is:
>>>>>>> org.apache.geronimo.javamail.transport.smtp.  So it is NOT a 
>>>>>>> base JVM implementation.... It's apache, and I am about to 
>>>>>>> withdraw my statement that 'surely the transport class couldn't be 
>>>>>>> ignoring a property".....
>>>>>>> 
>>>>>>> Geronimo's SMTPTransport.java uses a class SMTPConnection which 
>>>>>>> actually returns the localhost name.  And... no surprise at this 
>>>>>>> point, it totally ignores the mail.smtp.localhost property. The 
>>>>>>> property doesn't even appear anywher in the class.  First line 
>>>>>>> in getLocalHost() pulls the
>>>>>>> InetAddress.getLocalHost().getHostName() value.
>>>>>>> 
>>>>>>> So.... half the problem is done... we know the culprit. Now I 
>>>>>>> guess (oh joy....) I get to download the whole geronimo package, 
>>>>>>> set up a build process, fix the code, and replace the jar on my server. 
>>>>>>> (yuck).
>>>>>>> 
>>>>>>> That is... unless someone already has a VERY quick way to patch 
>>>>>>> and rebuild geronimo.....  Looking for volunteers.... :-)
>>>>>>> 
>>>>>>> In the meantime, I will also try adding that JVM parameter to 
>>>>>>> try to override the Win Server machine name.
>>>>>>> 
>>>>>>> Still open to other suggestions for quicker workaround.....
>>>>>>> 
>>>>>>> Thanks.
>>>>>>> 
>>>>>>> Jerry
>>>>>>> 
>>>>>>> ----------------------------------------------------------------
>>>>>>> ----- To unsubscribe, e-mail: 
>>>>>>> [email protected]
>>>>>>> For additional commands, e-mail: 
>>>>>>> [email protected]
>>>>>>> 
>>>>>>> 
>>>>>> 
>>>>>> -----
>>>>>> No virus found in this message.
>>>>>> Checked by AVG - www.avg.com
>>>>>> Version: 2015.0.5315 / Virus Database: 4189/8462 - Release Date:
>>>>>> 10/27/14
>>>>>> 
>>>>>> 
>>>>> ------------------------------------------------------------------
>>>>> --- To unsubscribe, e-mail: 
>>>>> [email protected]
>>>>> For additional commands, e-mail: [email protected]
>>>>> 
>>>> 
>>>> 
>>>> 
>>>> -----
>>>> No virus found in this message.
>>>> Checked by AVG - www.avg.com
>>>> Version: 2015.0.5315 / Virus Database: 4189/8463 - Release Date: 
>>>> 10/27/14
>>>> 
>>>> 
>>> 
>>> --------------------------------------------------------------------
>>> - To unsubscribe, e-mail: [email protected]
>>> For additional commands, e-mail: [email protected]
>>> 
>>> 
>>> 
>>> -----
>>> No virus found in this message.
>>> Checked by AVG - www.avg.com
>>> Version: 2015.0.5315 / Virus Database: 4189/8462 - Release Date: 
>>> 10/27/14
>>> 
>> 
>> 
>> ---------------------------------------------------------------------
>> 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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to