News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

WSADATA

Started by Fernand, September 27, 2007, 11:31:34 PM

Previous topic - Next topic

Fernand

Hi all of you, I need help
I am trying to make a small program to email data from one address to an other...

the DNS name is = videotron.ca  I am leaving in Quebec city
DNS = 205.151.222.250
SMTP = relais.videotron.ca

HELO db "smtp.videotron.ca",13 ,10 ,0
MAIL_FROM db "fxxxx@hotmail.com",0
RCPT_TO   db "fxxx@videotron.ca",0

Mys PROTO :DWORD
.data
buf db " testing testing",0
........
;        HELO SERVER     
invoke Mys, addr HELO                            ;envoit HELO smtp.videotron.ca
invoke recv, sock, addr buf, sizeof buf, 0

........
;        MAIL TO:
invoke Mys, addr MAIL_FROM                      ;envoit MAIL FROM:
invoke recv, sock, addr buf, sizeof buf, 0
........
;        RCPT TO:
invoke Mys, addr RCPT_TO                            ;envoit RCPT TO:
invoke recv, sock, addr buf, sizeof buf, 0

Mys proc SendStr : DWORD                           
push edi
mov edi, SendStr
.WHILE TRUE
.BREAK .IF (byte ptr [edi] == 0 )
invoke send, sock, edi, 1, 0                     
inc edi                                                 
.ENDW   
pop edi
ret
Mys endp

When I am running this program, I sended nothing and I did received nothing.
Fernand



realcr

Hi Fernand.

I believe the code you sent doesn't include some relevant parts  , so it can be hard to help you.
I would like to see the socket creation part.
Also you don't make any error checking. recv and send functions can return error codes.

I recommend you to try debug the program by checking all the winsock function return values. You could also use WireShark or any other network sniffing program to see the actual sent data and to make sure you application actually work.

realcr.

Fernand

HI realcr
Can you tell me more about WireShark
I debug my program with OLLYDBG... and it looks ok
Fernand



realcr

Wireshark is a program that used to observe data you send / recieve in the driver level.
It is really useful for networking programs debugging, as you can see the actual conversation.

You can download it free from here : http://www.wireshark.org/

realcr.

Tedd

First things:
Make sure you have called "WSAStartup", "socket", and "connect" - and that they were all successful. Not all servers will allow/provide a public smpt service.
Once you actually have a connection to the mail server, you will first receive a reply (one text line).
Then what you should be sending is:

db "EHLO fxxxx@hotmail.com",13,10
db "MAIL FROM:fxxxx@hotmail.com",13,10
db "RCPT TO:fxxx@videotron.ca",13,10
db "DATA",13,10
db "From: ""Fernand"" <fxxxx@hotmail.com>",13,10
db "To: ""Fernand II"" <fxxx@videotron.ca>",13,10
db "Subject: FW: your mail",13,10
db 13,10
db "This is an email.",13,10
db "It doesn't say much.",13,10
db "But no-one really cares.",13,10
db 13,10
db "[mail ends with a single '.' on a line by itself - this dot doesn't appear in the mail when received.]",13,10
db ".",13,10
db 0     ;null-terminator - don't send this.

And then close the connection.

Also, (again) I would strongly suggest NOT sending one byte at a time. You can easily get the length of the given string and send it all in one piece.

If you still have problems, you'll have to provide the whole code, not just a small piece of it.
No snowflake in an avalanche feels responsible.

Fernand

Hi Tedd. thanks for your reply.

How can I find a server that provide a public smpt service ?.
Fernand

Tedd

There are very few that allow public access - the ones that do soon get used for relaying junk mail and are quickly closed.
If your isp doesn't have one then you may be able to find a service that gives access for a monthly fee.
No snowflake in an avalanche feels responsible.