| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The smtp class, which is derived from protocol class,
implements RFC 821. It can be used only as a client. Server function
is not yet implemented.
smtp uses smtp::smtpbuf as its underlying stream buffer.
Also, like the protocol class, smtp is a smart pointer
class for it is smtp::smtpbuf.
In what follows,
s is an smtp object.
sb is an smtp::smtpbuf object.
io is a pointer to an ostream.
buf is a char buffer of length buflen.
str, str0, str1, ... are all char strings.
smtp s (io)
smtp client, s. Any response the client gets
from the server is sent to the ostream, io.
sb.get_response ()
io of the smtpbuf.
sb.send_cmd (str0, str1, str2)
str0, str1, and str2 and sends the
concatenated string to the server before getting its response.
sb.send_buf (buf, buflen)
buf to the server.
sb.helo ()
sb.help (str)
sb.quit ()
sb.turn ()
sb.rset ()
sb.noop ()
sb.data ()
sb.vrfy (str)
sb.expn (str)
sb.mail (str)
str is the the reverse path
or the FROM address.
sb.rcpt (str)
str is the forward path
or the TO address.
sb.data (buf, buflen)
buf as the mail data to the recipient
previously established through smtpbuf::rcpt() calls.
sb.data (filename)
filename as the mail data to the
recipient previously established through smtpbuf::rcpt() calls.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
// smtp client.
// The president sends a message to gs4t@virginia.edu.
#include <smtp.h>
#include <stdio.h>
#include <pwd.h>
#include <unistd.h>
int main ()
{
smtp client (&cout);
// establish connection
client->connect ("fulton.seas.virginia.edu");
client->helo ();
// get help
client->help ();
// setup the FROM address
client->mail ("president@whitehouse.gov");
// setup the TO address
client->rcpt ("gs4t@virginia.edu");
// send the message
client->data ();
client << "Hi Sekar, I appoint you as the director of NASA\r\n" << flush;
client << " -Bill, Hill, and Chel\r\n" << flush;
cout << client; // get the server response.
// finally quit
client->quit ();
return 0;
}
|
| [ << ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |