Simple Mail Transfer Protocol - RFC 821
has all of the relevelant information you need to send an email message. You will need to read through it to really get an idea of what you're trying to do. Here are the basic steps to get you started:
- Open a socket to your SMTP server (usually on port 25).
- HELO (or EHLO)
- MAIL FROM your[/b]@return address
- RCPT TO first[/b]@recipient
- RCPT TO second[/b]@recipient
- Email headers go here
- Body of the email goes here
- $crlf $+ . $+ $crlf
At each step of the way, you will have to wait for the server to respond (except during the DATA section when it waits for your DATA section to be complete). The server will respond with numerics that tell your script if a command failed or succeeded.
I've found that it's simplest to create a dialog for the email user interface and write the results to a file. That way, you can keep track of which line you're on in the sending process and send the correct data and the correct time. MOST of your socket script will be in the on SOCKREAD event, responding to the numerics you receive from the server and then sending out the next line.
You "can" just use timers to send the data without waiting for the server to reply to you, but you can occasionally get messages sent the server is not ready for (the error you receive is something like "lines out of order").This page
might also help you better understand how SMTP works.