flat assembler
Message board for the users of flat assembler.

Index > Windows > SMTP with winsock?

Author
Thread Post new topic Reply to topic
OzzY



Joined: 19 Sep 2003
Posts: 1029
Location: Everywhere
OzzY
Anyone have an example of programming a simple SMTP mailer using winsock?
I can send e-mails using telnet, but can't do it in programming.
Also, if you have information about sending attachments, please provide.

Thanks
Post 05 Nov 2006, 18:54
View user's profile Send private message Reply with quote
r22



Joined: 27 Dec 2004
Posts: 805
r22
OzzY you just have to research the Winsock api in MSDN.

Here are the functions you'd need.

library winsock,'WS2_32.DLL'
import winsock,\
WSAStartup,'WSAStartup',\
WSACleanup,'WSACleanup',\
socket,'socket',\
connect,'connect',\
recv,'recv',\
send,'send',\
closesocket,'closesocket'

You'd start with WSAStartup then create a socket handle with the 'socket' then you'd use 'connect' to connect to the SMTP server then you'd 'send' your SMTP protocol data.
After the connect or the send you may also want to use recv to check the replies from the server.

As for sending attachments, if I'm not mistaken the files are 64bit encoded and a different MIME header is used in the email.
If you really want to research the topic you can download a packet sniffer like Ethereal and sniff an outlook express (or any other email client) send. This will let you verify the format of the header information in the email and such.

I'm sure if you look hard enough on google you may find an example of the SMTP protocol usage (probably written in C or C++).
Post 05 Nov 2006, 20:23
View user's profile Send private message AIM Address Yahoo Messenger Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
It's base64, but it doesn't means 64-bit but a way of using ASCII chars to represents binary values from 0 to 63. Since every byte can go from 0 to 255, you need more than one base64 char to represent a binary byte (and some base64 chars mixes two binary bytes).

Here a link http://en.wikipedia.org/wiki/Base64
Post 05 Nov 2006, 21:12
View user's profile Send private message Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo
Don't forget decard's base64 lib w/ demo (Win32, I think).

Quote:

Base64
Base64 encoding/decoding library, and a demo utility which encodes and decodes single files.

size: 5 kb
updated: 25-07-2005
Post 05 Nov 2006, 22:06
View user's profile Send private message Visit poster's website Reply with quote
OzzY



Joined: 19 Sep 2003
Posts: 1029
Location: Everywhere
OzzY
Great news: I could send my first mail from C code!!
*Feels like a child learning to say the first words*
Soon, I'll try to make a FASM Simple SMTP Client and post in project section!! Smile
Post 06 Nov 2006, 17:45
View user's profile Send private message Reply with quote
OzzY



Joined: 19 Sep 2003
Posts: 1029
Location: Everywhere
OzzY
When I send a message it goes to spam folder. Is there a way to prevent it?
Post 07 Nov 2006, 00:49
View user's profile Send private message Reply with quote
UCM



Joined: 25 Feb 2005
Posts: 285
Location: Canada
UCM
It depends. One way is to set "X-Priority: 3" for some Hotmail filters.
Post 08 Nov 2006, 00:37
View user's profile Send private message Reply with quote
okasvi



Joined: 18 Aug 2005
Posts: 382
Location: Finland
okasvi
I think that you dont use headers (and/or use X-client or w/e) that most mailers use, so it's classified as spam... you should try sending email with ie. outlook and view the headers it fills for normal email...
Post 10 Nov 2006, 15:13
View user's profile Send private message MSN Messenger Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.