 |
 |

04-07-2008, 08:38 AM
|
 |
Tachikoma
|
|
Join Date: Mar 2003
Location: Mansfield, UK
Posts: 4,594
|
|
Sending SMTP Lines
|
Hi. I have a question about sending lines in an SMTP connection. Ive read the protocol (yep, i was completely bored). It mentions sending lines and how they must end with a CrLf. Now for a multi-line response i understand that you put the status code on every line followed by a dash (no dash on the last line though).
I have been trying to send a reply to EHLO which should look something like this
250-ServerName Hello [its.my.ip.address]
250-AUTH LOGIN
250 OK
From what ive read in the protocol that should be fine. I told a mail client to send an email to it and it said EHLO fine and my server replied fine but the mail client didnt do anything.
Ive also tested with telnet and it seems that only the first line gets through. Can anyone explain whats happening please? All the data is definately being sent out
Edit: If i connect using telnet on localhost then it works fine. It doesnt work when i connect accross the internet. I have noticed that if i press enter the missing lines will come in one at a time for each keypress. Those keypresses are also sent to the server
Edit: Just thought i would mention that im using an array of winsock controls
|
Last edited by the master; 04-07-2008 at 09:06 AM.
|

04-07-2008, 10:51 AM
|
 |
Underclocked lifestyle
Forum Leader * Guru *
|
|
Join Date: Feb 2005
Location: Michigan, USA
Posts: 4,184
|
|
Sounds as if your Telnet client is perhaps only sending Cr on each Enter-press in some cases. Despite everyone seeming to think this is clever, I doubt that using a Telnet client is the best way to troubleshoot SMTP.
You might roll your own "raw TCP" client for this sort of thing if your Telnet client doesn't have a "raw" command line switch. Some of the pitfalls of using a Telnet client can be seen at TELNET.
|
|

04-07-2008, 11:40 AM
|
 |
Tachikoma
|
|
Join Date: Mar 2003
Location: Mansfield, UK
Posts: 4,594
|
|
|
Thats an interesting idea. I though about making a basic telnet type thing because it gets so annoying having to retype the host and port everytime. Now heres another reason so i think i will go ahed and try it.
The telnet client im having trouble with is on Vista. I thought it would have been the same as the XP one (i dont see how it could be changed). I dont think the problem is that its sending Cr though. My server (as per the protocol document) will only do anything if it receives a full CrLf. It does react and it does send the data. Ive actually tried sending each line seperately with upto 30 seconds between each line and ive tried joining them into 1 string and sendimg them all together but i get the same problem.
Ive also tested my other server which is running the windows SMTP server (this is the one ive had trouble with recently). Telnet can connect to it without a problem and works just how i expected mine to.
Ive just tested it on a different PC thats on the same network as the test server and it works fine using both the network address and the remote address.
Edit: Does it matter that im running it on port 110? This server is still running an email server on port 25 and port 25 is blocked by my router since this server can relay mail to no-ip's server. I dont need a POP server on this one so i used port 110. I cant see why this should affect it but i guess anythings possible
|
|

04-07-2008, 04:23 PM
|
 |
Underclocked lifestyle
Forum Leader * Guru *
|
|
Join Date: Feb 2005
Location: Michigan, USA
Posts: 4,184
|
|
I doubt that the port number is an issue, though I don't care to reuse well-known port numbers for incompatible purposes. I'd have chosen 8025 but that's just me. List of TCP and UDP port numbers.
Ignoring that, if the Telnet client can interoperate with a known SMTP server properly (i.e. as you'd expect) I hate to say it but something must be wrong with your code in your custom SMTP server.
|
|

04-08-2008, 02:07 AM
|
 |
Tachikoma
|
|
Join Date: Mar 2003
Location: Mansfield, UK
Posts: 4,594
|
|
Im only using 110 because its already setup. I will use port 25 for when its actually running.
I thought it must be my code because everything else seems to work fine.
I have a send sub so i can easily switch to winsock API later.
Code:
Private Sub SendReply(ByVal Data As String, ByVal Index As Integer)
frmMain.sckSMTP(Index).SendData Data
End Sub
And its used like this
Code:
'Return the new style reply with a list of extensions
SendReply "250-" & modMain.strServerName & " Hello [" & GetClientIP(Index) & "]" & vbNewLine, Index
SendReply "250-AUTH=LOGIN" & vbNewLine, Index
SendReply "250-AUTH LOGIN" & vbNewLine, Index
SendReply "250 OK" & vbNewLine, Index
I have also tried putting them all into a string first and sending all in one go but with the same result.
I tried using vbCrLf instead of vbNewLine too. vbNewLine is platform specific aparently but on windows (what im using) its the same as vbCrLf anyway.
Im not exactly new to winsock. Ive done this kind of thing before and its always worked perfectly. The strange thing is that it works perfectly on localhost and any of my local PCs just not remotely.
|
|

04-08-2008, 02:27 AM
|
 |
Tachikoma
|
|
Join Date: Mar 2003
Location: Mansfield, UK
Posts: 4,594
|
|
I just thought i would try changing the port. I took the built in server down and ran mine on port 25 and it works perfectly
I dont know for sure but i would guess my router is to blame. Ive tried adding more ports to port forwarding like 3325 and 9090 but i cant even get a connection on those. They are allowed by the windows routing and remote access too.
Ive managed to get it working on port 21. This server hasnt got FTP so it should be alright for testing
|
|

04-08-2008, 10:48 AM
|
 |
Underclocked lifestyle
Forum Leader * Guru *
|
|
Join Date: Feb 2005
Location: Michigan, USA
Posts: 4,184
|
|
|
Wow, that's different.
vbNewLine is only different on a Mac as far as I know. I'm not aware of any VB/VBA/VBScript on *nix platforms, but if so it'd be different there yet again.
Hard to see how the router would interfere, but clearly there is some difference by port. I would not be surprised to find that the Telnet client handles certain well-known ports as special cases too.
The stuff after the 1st 250 line is domain and then optional comments (greeting). I don't think you need any IP address there at all. Then again I'm not reading the RFCs right now so I might be all wet.
|
|

04-08-2008, 11:21 AM
|
 |
Tachikoma
|
|
Join Date: Mar 2003
Location: Mansfield, UK
Posts: 4,594
|
|
|
It sounds like a "telnet client" isnt exactly what i thought it was. Ive always known telnet to be the program that comes with windows (except Vista i think) that gives you a command prompt window and allows you to connect to another PC. I thought that any data i entered would be sent asif i was calling winsock.senddata "test" in VB.
I have spent most of the day writing a new SMTP server in pseuedo code (i think thats the correct term). Ive run through the whole thing several times in my head and it looks like it should work. The next step is obviously to convert it to real VB code. I will be replacing vbNewLine with vbCrLf just to be on the safe side because the protocol says <CRLF> only.
I dont think telnet is handling different ports differently. The reason i used telnet in the first place is because windows live mail kept stopping asif the server hadnt replied. Now im running on port 21 even WLM seems to work fine
As i understand it the text part of a reply in the basic part of ESMTP (excluding extensions) can be anything you want as its only there for a human to read. The RFC shows "250 Requested mail action okay, completed". My first line is based on the one sent from the built in Windows SMTP server although i suspect that doesnt follow the standards strictly.
I did take your advice and made my own telnet style client. Ive added buttons to convert parts of the text to and from base64 too so its easy to test the AUTH extension
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Hybrid Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
|
|
 |
|