Advertisement

Sending email via winsock2 SMTP

Started by October 29, 2005 07:19 AM
4 comments, last by hplus0603 19 years, 3 months ago
I have looked in the tutorials sections but I havnt found what I need. I only want to send email from the user computer using winsock2, SMTP, but with my own code. So I need a good specific tutorial that does that. Do you know any such tutorial? Thanks in advance.
It's all about the wheel.Never blindly trust technoligy.I love my internal organs.Real men don't shower. Quote: Original post by Toolmaker Quote: Original post by The C modest godHow is my improoved signature?It sucks, just like you.
A Google Search would lead you to RFC 821 which describes the SMTP protocol.

If you want to just fake it, then connect to port 25 using TCP, and send the following data:

MAIL FROM: {from-address}RCPT TO: {to-address}DATA{mail headers go here}{mail body goes here}.


Note that line endings need to be cr-lf to be SMTP compliant. Also note that many servers require authentication, or that the FROM address comply with some specific criteria, or that the source address is within a local subnet.
enum Bool { True, False, FileNotFound };
Advertisement
I am just looking for a simple tutorial for sending an email using Winsock2, which will require the least requirements from the user's computer (i.e. installed components etc)
I don't want to learn how to write a multiplayer game with winsock2 or the whole SMTP protocol.

Is there something like this out there?
It's all about the wheel.Never blindly trust technoligy.I love my internal organs.Real men don't shower. Quote: Original post by Toolmaker Quote: Original post by The C modest godHow is my improoved signature?It sucks, just like you.
Quote:
connect to port 25 using TCP, and send the following data


If you don't even know how to create a TCP connection, then there are tons of tutorials for that out there. For example, the HTTP-GET code connects to port 80, sends some data, and then receives data. You can just change that code to connect to port 25, and send the mail as data instead of the HTTP GET request; that should be a trivial change.
enum Bool { True, False, FileNotFound };
What is port 25?
Does sending email this way has the least requirements from the platform?
Also, will I be able to attach a file to the mail with this?
It's all about the wheel.Never blindly trust technoligy.I love my internal organs.Real men don't shower. Quote: Original post by Toolmaker Quote: Original post by The C modest godHow is my improoved signature?It sucks, just like you.
Please, read through the Beej Networking Tutorial; it will tell you what TCP is and what ports are. (Port 25 is the SMTP service on your mail server)

You can send attachments by putting the appropriately formatted strings in the header and body of your e-mail -- the RFC linked to in the original answer tells you exactly how to do that.
enum Bool { True, False, FileNotFound };

This topic is closed to new replies.

Advertisement