| 1 |
ab11 |
1.1 |
#include <smtp.h> |
| 2 |
|
|
#include <stdio.h> |
| 3 |
|
|
#include <pwd.h> |
| 4 |
|
|
#include <unistd.h> |
| 5 |
|
|
|
| 6 |
|
|
int main (int ac, char** av) |
| 7 |
|
|
{ |
| 8 |
|
|
if (ac < 4) { |
| 9 |
|
|
cerr << "USAGE: " << av [0] << " host recipient files...\n"; |
| 10 |
|
|
return 1; |
| 11 |
|
|
} |
| 12 |
|
|
|
| 13 |
|
|
smtp client (&cout); |
| 14 |
|
|
|
| 15 |
|
|
// establish connection |
| 16 |
|
|
client->connect (av [1]); |
| 17 |
|
|
client->helo (); |
| 18 |
|
|
|
| 19 |
|
|
// get help |
| 20 |
|
|
client->help (); |
| 21 |
|
|
|
| 22 |
|
|
// get the FROM address |
| 23 |
|
|
char sender [256]; |
| 24 |
|
|
passwd* pw = getpwuid( getuid() ); |
| 25 |
|
|
sprintf(sender, "%s@%s", pw->pw_name, client->localhost()); |
| 26 |
|
|
|
| 27 |
|
|
// send the files |
| 28 |
|
|
for (int i = 3; i < ac; i++) { |
| 29 |
|
|
client->mail (sender); |
| 30 |
|
|
client->rcpt (av [2]); |
| 31 |
|
|
client->data (av [i]); |
| 32 |
|
|
client->rset (); |
| 33 |
|
|
} |
| 34 |
|
|
|
| 35 |
|
|
// finally quit |
| 36 |
|
|
client->quit (); |
| 37 |
|
|
|
| 38 |
|
|
return 0; |
| 39 |
|
|
} |