There's probably something around here on talking to smtp servers.
But basically, you just open a socket to the server, and speak SMTP
to it. Get the RFQ (sorry, I don't remember the number) and find
out all the gory details, but a simple transaction looks like this (the
SMTP server says the lines in italics, you say the other ones.):
<i>220 mail.null.com ESMTP Sendmail ...</i>
HELO fly-by-night
<i>250 mail.null.com Hello fly-by-night [10.0.0.1], pleased to meet you</i>
MAIL FROM: <me@my.com>
<i>250 <me@my.com>... Sender ok</i>
RCPT TO: <you@you.com>
<i>250 <you@you.com>... Recipient ok</i>
DATA
<i>354 Enter mail, end with "." on a line by itself</i>
From: me@my.com
To: you@you.com
Subject: Sample SMTP transaction
This is the body of the email.
..
Be sure to double any period that occurs on a line
by itself in the body of the message, otherwise the
message will end prematurely!
.
<i>250 WAA05710 Message accepted for delivery</i>
quit
Note that the numeric code at the beginning of the server lines tells you everything you need to know about the server status; the rest is just for human readers (including for logging purposes.)
Note, too, that you can include as many RCPT TO: lines as you wish, to send the body of the message to any number of recipients.
And finally, the header lines that the recipient sees turn out not to be headers at all, from the pov of the smtp server: these all go at the head of the body of the message, right after the DATA command.