Finally I finished this simple mail sender !!!!

It works pretty fine even if it's really simple ...

Thx for everyone who's helped me and answered my question

I believe this is the simplest one so probably easy to understand how smtp mail server works....

Good luck all !!!
Posted on 2002-05-12 19:38:57 by Gandalf
hi, nice code :alright:, though it would be proper if it handles smtp messages or codes, to check for errors (you know the first three numbers the server replies you? they're it. e.g. 250 recipient ok!), they would indicate problems on the server and problems on your parameters. refer to the rfc for the codes and their meanings.
Posted on 2002-05-12 21:36:55 by clip
Pretty good Gandalf. :) Now we wait the mail receiver :tongue:
Posted on 2002-05-13 15:20:25 by CodeLover
Ok.. im very new to all this stuff, in the most part i siliently monitor posts and examples hoping to learn something ;)

But after downloading your source, should there be a RSRC file as well? It compiles well.. just doesn look or do much. :)

As well, cause im dumb with this stuff, do i *need* to find a valid server name? or will something like ??? work.?

Thanx for the source... the code is nicely organized :)
Posted on 2002-06-03 12:49:32 by NaN
I just see a window that dosen't do anything?
Posted on 2002-06-03 12:59:29 by Kudos
Thats my point, if you look thu his source, you can see it expects some command messges.. and somehow, other networking-type messages that im too green to know about ;)

Posted on 2002-06-03 14:32:09 by NaN
I had resource file but that contains only ico file ....

from db "mail from:whatever@whatever",13,10 ;tell where your address
send_to db "rcpt",13,10 ; whom you wanna send to
data1 db "data",13,10
data db "Put here whatever you wanna say",13,10,".",13,10
quit db "quit",13,10
hostname db "any smtp server name",0
hello db "helo any smtp server name",0dh,0ah
wsadata WSADATA <>
ClassName db "Gandalf",0
AppName db "Gandalf Client",0
Port dd 25 ; smtp port = always 25
sin sockaddr_in <>


from db "mail",13,10 ;you can say where is this mail is from 'mail from:' is command for smtp server you can check these commands from RFC site

send_to db "rcpt",13,10 ; "rcpt to:" is command that tells the server who is receiver

data1 db "data",13,10 ;this one is used as a command ... data is command that tells the server to send data

data db "some data or whatever you wanna send",13,10,".",13,10 ; you can tell the server you sent all data you wanna send with 13,10 and "." and 13,10 again ...

hostname db "",0 ; put any smtp server name you wanna connect and send email ... you can see code that converts this address to ip address

hello db "helo",0dh,0ah ; you gotta send command "helo your.smtp.address",13,10 right after connect you can check this command also from rfc site

invoke WSAStartup,101h,addr wsadata
.if eax!=0
invoke MessageBox,0,addr StartupError,0,MB_OK

invoke socket,AF_INET,SOCK_STREAM,0
invoke MessageBox,0,addr socketError,0,MB_OK

mov sock,eax
invoke WSAAsyncSelect,sock,hwnd,WM_SOCKET,FD_CLOSE+FD_READ
invoke MessageBox,0,addr selectError,0,MB_OK
just open the socket

.elseif uMsg==WM_COMMAND
mov eax,wParam
mov something,ax
mov sin.sin_family,AF_INET
invoke htons,Port
mov sin.sin_port,ax
invoke gethostbyname,addr hostname
.if eax==0
invoke MessageBox,0,addr error1,0,MB_OK
mov eax,
mov eax,
mov eax,
mov sin.sin_addr,eax
invoke connect,sock,addr sin,sizeof sin

invoke WSAGetLastError
.if eax==WSAEINVAL
invoke MessageBox,0,addr error1,0,MB_OK
.elseif eax==WSAEISCONN ;some error checking ....
invoke MessageBox,0,addr error2,0,MB_OK
invoke MessageBox,0,addr error3,0,MB_OK
.elseif eax==WSAENOBUFS
invoke MessageBox,0,addr error4,0,MB_OK
invoke MessageBox,0,addr error5,0,MB_OK
.elseif eax==WSAENOTSOCK
invoke MessageBox,0,addr error6,0,MB_OK

invoke MessageBox,0,addr error7,0,MB_OK
If user click connect button, connect the server and check if there is any error

.elseif something==IDM_SEND

invoke send,sock,addr hello,sizeof hello,0
;gotta send "helo" right after connect
.if eax==sizeof hello ;error checking
invoke MessageBox,0,addr error7,0,MB_OK

invoke send,sock,addr from,sizeof from,0
;send "mail from:whatever@whatever",13,10 always 13,10 after one command
.if eax==sizeof from ; error checking
invoke MessageBox,0,addr error7,0,MB_OK

invoke send,sock,addr send_to,sizeof send_to,0
;send "rcpt",13,10
.if eax==sizeof send_to
invoke MessageBox,0,addr error7,0,MB_OK

invoke send,sock,addr data1,sizeof data1,0
;send "data",13,10 this one is just command that tells the server you will send some messages after this command
.if eax==sizeof data1
invoke MessageBox,0,addr error7,0,MB_OK

invoke send,sock,addr data,sizeof data,0
;send messages and tell server that's all with 13,10,".",13,10
.if eax==sizeof data
invoke MessageBox,0,addr error7,0,MB_OK

invoke send,sock,addr quit,sizeof quit,0
;send "quit" messages which will close the connection
.if eax==sizeof quit
invoke MessageBox,0,addr error7,0,MB_OK

I guess that's it and if you guys have any question just leave the message ...
Posted on 2002-06-04 01:23:49 by Gandalf
Sorry guys ....

I forgot there was resource file ... duh

Yep you guys are right there are two menus in the resource file ...

Connect and Send ....

I thought that was pretty understandable without resource file ...

Anyway my bad and there is file
Posted on 2002-06-04 01:29:48 by Gandalf
Thanx Gandalf :alright:

PS: side thought here, but, I got Network Programming For Microsoft Windows by Anthony Jones & Jim Ohlund from a friend.. Does anyone know of this book? Is it worth butting time into?

Posted on 2002-06-04 12:54:21 by NaN
...PS: side thought here, but, I got Network Programming For Microsoft Windows by Anthony Jones & Jim Ohlund from a friend.. Does anyone know of this book? Is it worth butting time into?

NAN, I have that book. It doesn't devote as much content to tcp/ip sockets as one would like, but it's still a good read. The real gems are on the accompanying CD.
Posted on 2002-06-05 01:59:27 by iblis
Thanx for your thoughts ;)

Posted on 2002-06-05 13:45:52 by NaN