SMTPClient uses local address

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

SMTPClient uses local address

Sean P. DeNigris
Administrator
SMTPClient>>initiateSession
        ...
        self sendCommand: ... NetNameResolver localHostName.
        ...

This results in the local address (e.g. 10.0.0.5) being used, which sometimes gets kicked back by the mail server with:
    550-"JunkMail rejected - ool-182daabe.dyn.optonline.net (10.0.0.5)

Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: SMTPClient uses local address

Sean P. DeNigris
Administrator
Issue 5078: SMTPClient (wrongly) uses local address
http://code.google.com/p/pharo/issues/detail?id=5078

I have no idea how to fix it. I cheated in my image with "(PipeableOSProcess waitForCommand: 'curl whatismyip.org') output" to get it to work temporarily.
Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: SMTPClient uses local address

Sven Van Caekenberghe

On 09 Dec 2011, at 23:06, Sean P. DeNigris wrote:

> I have no idea how to fix it. I cheated in my image with "(PipeableOSProcess
> waitForCommand: 'curl whatismyip.org') output" to get it to work
> temporarily.

This cannot be fixed I think: how could you find out the IP address that your router has on the internet while you are on an (wireless) internal network at home or in the office ?

But I am not a network specialist, so who knows ?

Sven
Reply | Threaded
Open this post in threaded view
|

Re: SMTPClient uses local address

NorbertHartl
In reply to this post by Sean P. DeNigris
Sean,

Am 09.12.2011 um 23:06 schrieb Sean P. DeNigris:

Issue 5078: SMTPClient (wrongly) uses local address
http://code.google.com/p/pharo/issues/detail?id=5078

I have no idea how to fix it. I cheated in my image with "(PipeableOSProcess
waitForCommand: 'curl whatismyip.org') output" to get it to work
temporarily.

I'm sure this is not a bug. Using your local address ist the only thing you can do. The entry is only put in the mail header/envelope and usually has no effect at all. It wouldn't be to clever if a mail server would take the IP address from your produced mail header instead of the IP packet header. :) The later is checked indeed. In your copied snippet

   550-"JunkMail rejected - ool-182daabe.dyn.optonline.net (10.0.0.5)

you can see that 10.0.0.5 is considered as the one you told the server but it treats you to be ool-182daabe.dyn.optonline.net which is 24.45.170.190. So your router did network translate your IP to a real IP and the mail server saw it in the connect from this IP address. Exactly as it is supposed to be. 
Analyzing your problem I focus on the "dyn" word in it. That means to me you are probably using a dialup or similar line from home. These are always considered to be not trusted. So If you try to use the mail server to send an email to someone that is not a user on this mail server you will need relaying permission which means you need to log in somehow to the mail server. In nearly every other case a mail server will reject your trial of sending messages. Another reason why it probably doesn't work is because your dynamically assigned IP address is blacklisted. I checked the mentioned IP address over


and at least spamhaus has this IP address listed which is a very prominent RBL service. The addresses are added and removed automatically so this could also be a reason why it worked some day and now it doesn't.

If you are using SMTP services you need a machine that is trusted or you need to use SMTP Auth to make the mail server accept your requests. Of course I do not know what is the problem exactly because that would need further investigation. 

hope this helps,

Norbert

Reply | Threaded
Open this post in threaded view
|

Re: SMTPClient uses local address

Sean P. DeNigris
Administrator
Norbert Hartl wrote
Analyzing your problem I focus on the "dyn" word in it. That means to me you are probably using a dialup or similar line from home. These are always considered to be not trusted... The addresses are added and removed automatically so this could also be a reason why it worked some day and now it doesn't.
Norbert, thanks for all the details! Yes, this all sounds right, especially because the errors are intermittent. So the use of the local address does not seem to be the cause of the error, but it still doesn't seem right to me to pass the private address to the outside world.

Norbert Hartl wrote
you need to use SMTP Auth to make the mail server accept your requests.
Ah, yes! Very good. I was using the one-shot methods on the class-side of SMTPClient, which do not expose this part of the API.

I wonder if they could. I think they'd be more useful. Right now, to send a message with credentials, it seems you'd have to write:
    csmtpClient := SMTPClient new
        user: 'username';
        password: 'pwd';
        openOnHost: (NetNameResolver addressForName: 'mail.myserver.com' timeout: 20) port: smtpPort.
  [smtpClient initiateSession.
        smtpClient mailFrom: fromAddress to: recipientList text: messageText.
        smtpClient quit]
                ensure: [smtpClient close].

Yuck.


Sean
Cheers,
Sean