SMTPmail problem

vdennis

Member
We are in the process of adding a new exchange server and when running test on the unix side I am now getting the 501.5.5.4 invalid domain name error. When I run the exact same code on my local, windows box it works fine. I doubled check the 'connection with the following code:
def var hSocket as handle.
def var mailhub as char initial 'xxx.xxxx-xxxxx.com'.
def var iPortNum as integer initial 25.
CREATE SOCKET hSocket.
hSocket:CONNECT("-H " + entry(1,MailHub,":") +
" -S " + string(iPortNum)) NO-ERROR.
IF hSocket:CONNECTED() = FALSE THEN DO:
message
"No Connection"
view-as alert-box.

RETURN.
END.
else do:
message
"Made the connection"
view-as alert-box.
end.
So I know I can make the connection, both in windows and UNIX.
And the test program, when run on a windows box works fine. Sample Code:

{vars-smtp.i}
/** Added for testing in Char **/
def var v-body as longchar .
def var c-ReadLine as char no-undo.
def stream s-vbody .

message
"Mail Hub Is " mailhub
view-as alert-box.

ASSIGN
EmailTo = "Dennis.Voegler@Adams-Burch.com"
EmailFrom = "Dennis.Voegler@Adams-Burch.com"
EmailCC = ""
Attachments = ""
LocalFiles = ""
Subject = "Test to send Email as HTML"
BodyType = "".

/**/
RUN "smtpmail.p"
(INPUT mailhub,
EmailTo,
EmailFrom,
EmailCC,
Attachments,
Localfiles,
Subject,
Body,
MIMEHeader,
BodyType,
Importance,
L_DoAUTH,
C_AuthType,
C_User,
C_Password,
OUTPUT oSuccessful,
OUTPUT vMessage).
/**/
message
oSuccessful skip
vMessage
view-as alert-box.
/**/
stop.
But when run on the UNIX box, we get the error.

Any thoughts on this?

-Dennis-
 

vdennis

Member
Problem solved:
Seems that in the UNIX side, the new HOSTs need to be set up in the /ect/hosts directory. The Windosw side is abe to use the DNS address, but not on the Unix Box.
-Dennis-
 

Stefan

Well-Known Member
Problem solved:
Seems that in the UNIX side, the new HOSTs need to be set up in the /ect/hosts directory. The Windosw side is abe to use the DNS address, but not on the Unix Box.
-Dennis-

Then you did not tell the truth in your inital post, since there you state:

We are in the process of adding a new exchange server and when running test on the unix side I am now getting the 501.5.5.4 invalid domain name error. When I run the exact same code on my local, windows box it works fine. I doubled check the 'connection with the following code:
Code:
[COLOR=#333333]def var hSocket as handle.[/COLOR]
[COLOR=#333333]def var mailhub as char initial 'xxx.xxxx-xxxxx.com'.[/COLOR]
[COLOR=#333333]def var iPortNum as integer initial 25.[/COLOR]
[COLOR=#333333]CREATE SOCKET hSocket.[/COLOR]
[COLOR=#333333]hSocket:CONNECT("-H " + entry(1,MailHub,":") + [/COLOR][COLOR=#333333]" -S " + string(iPortNum)) NO-ERROR.[/COLOR]
[COLOR=#333333]IF hSocket:CONNECTED() = FALSE THEN DO:[/COLOR]
[COLOR=#333333]   message[/COLOR][COLOR=#333333] "No Connection" [/COLOR][COLOR=#333333]view-as alert-box.[/COLOR]
[COLOR=#333333]   RETURN.[/COLOR]
[COLOR=#333333]END.[/COLOR]
[COLOR=#333333]else do:[/COLOR]
[COLOR=#333333]   message [/COLOR][COLOR=#333333]"Made the connection" [/COLOR][COLOR=#333333]view-as alert-box.[/COLOR]
[COLOR=#333333]end.
[/COLOR]
So I know I can make the connection, both in windows and UNIX.


The connection on unix would also have failed if there were an issue with the HOSTS file.
 

vdennis

Member
To say I did not tell the truth is rather strong. I would suggest that you try and duplicate what I did as I was able to make the connection the host, but because the host name was not tied to an ip address (i.e. 10.0.x.xxx) it could not find the Domain Name used as the exchage mail server from the UNIX box.
 

vdennis

Member
I responded too soon; Yes, we can see the host, and no, still getting an invalid domain name error. We are thinking it is a RELAY problem, as I am seeing RESP:220 <New Exchange Server> where I normally should see RESP 250 <Origianl exchange server>. In looking at the socketmail.log file, a correct responce is:
01/16/12 11:00:23 Begin read state 1
RESP:220 Original.adams-burch.com Microsoft ESMTP MAIL Service, Version: 6.0.3790.4675 ready at Mon, 16 Jan 2012 10:59:09 -0500
01/16/12 11:00:23 1 220 HELO
01/16/12 11:00:23 newstate 5
CLIENT:HELO hostname:Notarecognizedflag:f
01/16/12 11:00:23 End read state 5
01/16/12 11:00:24 Begin read state 5
RESP:250 Original.adams-burch.com Hello [10.0.1.101]

Error Log:

RESP:220 New.adams-burch.com Microsoft ESMTP MAIL Service ready at Mon, 16 Jan 2012 11:03:03 -0500
01/16/12 11:04:18 1 220 HELO
01/16/12 11:04:18 newstate 5
CLIENT:HELO hostname:Notarecognizedflag:f
01/16/12 11:04:18 End read state 5
01/16/12 11:04:23 Begin read state 5
RESP:501 5.5.4 Invalid domain name

So as you can see, it is not a connection error otherwise I would have gotten a messae stating such. When we find the answer, I'll post it.
-Dennis-
 

Stefan

Well-Known Member
When I initially googled the error icm with smtp I recall finding something about some (newer?) smtp servers requiring a trailing dot or space after HELO.

Or are you simply not getting a result from the hostname function in smtpmail.p? The combination of hostname and f smells a lot like hostname -f which works on some but not all *nixes.
 

vdennis

Member
Found the error problem.
In the file gethostname.p unfrt unix you have code that reads :
INPUT {&SC} THROUGH VALUE("hostname -f"). /* if this doesn't work on your platform, try uname -n */

The problem is that the new exchange servers are more demanding as we where getting:

LocalHostName = hostname:Notarecognizedflag:f

as the response in the socketemail.log file. Our older version of exchage could handle this as part of the telnet exchange, but it appears newer versions cannot. Upon removing the '-f' the response now is:
LocalHostName = serenity

which is the name of the unix host and problem solved.
-Dennis-
 

Stefan

Well-Known Member
Found the error problem.
In the file gethostname.p unfrt unix you have code that reads :
INPUT {&SC} THROUGH VALUE("hostname -f"). /* if this doesn't work on your platform, try uname -n */

The problem is that the new exchange servers are more demanding as we where getting:

LocalHostName = hostname:Notarecognizedflag:f

as the response in the socketemail.log file. Our older version of exchage could handle this as part of the telnet exchange, but it appears newer versions cannot. Upon removing the '-f' the response now is:
LocalHostName = serenity

which is the name of the unix host and problem solved.
-Dennis-

The issue has nothing to do with Exchange, it is with your Linux / Unix not understanding hostname -f which is exactly why the comment /* if this dosn't work on your platform, try uname -n */ is on that line.

Try typing hostname -f on the command line and you will see that you get the error:

hostname: Not a recognized flag: f (or something similar)

If I hostname -f no AIX 4.3 I get the return text:

Code:
hostname: illegal option -- f
usage: hostname [-s] [hostname]

This returned error is simply being passed as 'hostname' to Exchange which then replies with a wtf.
 

vdennis

Member
You missed the point. No change has been made to the UNIX side, only the new exchange servers. Prior to that it worked fine, so we were thinking that there was a relay problem, we just did not know where. The older version of MS Exchange accepted the error, while the new does not. So the question is, what changed? The exchange servers did and hence the failure. We spent about 3 hours trying to track down where the error was coming from. In the long run, it did make us aware of another problem that we didn't even know existed, so all was not in vain.
 
Top