3
0

sendmail.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * bare bones sendmail/fetchmail
  4. *
  5. * Copyright (C) 2008 by Vladimir Dronnikov <dronnikov@gmail.com>
  6. *
  7. * Licensed under GPLv2, see file LICENSE in this tarball for details.
  8. */
  9. #include "libbb.h"
  10. #define INITIAL_STDIN_FILENO 3
  11. static void uuencode(char *fname, const char *text)
  12. {
  13. enum {
  14. SRC_BUF_SIZE = 45, /* This *MUST* be a multiple of 3 */
  15. DST_BUF_SIZE = 4 * ((SRC_BUF_SIZE + 2) / 3),
  16. };
  17. #define src_buf text
  18. int fd;
  19. #define len fd
  20. char dst_buf[DST_BUF_SIZE + 1];
  21. if (fname) {
  22. fd = INITIAL_STDIN_FILENO;
  23. if (NOT_LONE_DASH(fname))
  24. fd = xopen(fname, O_RDONLY);
  25. src_buf = bb_common_bufsiz1;
  26. // N.B. strlen(NULL) segfaults!
  27. } else if (text) {
  28. // though we do not call uuencode(NULL, NULL) explicitly
  29. // still we do not want to break things suddenly
  30. len = strlen(text);
  31. } else
  32. return;
  33. fflush(stdout); // sync stdio and unistd output
  34. while (1) {
  35. size_t size;
  36. if (fname) {
  37. size = full_read(fd, (char *)src_buf, SRC_BUF_SIZE);
  38. if ((ssize_t)size < 0)
  39. bb_perror_msg_and_die(bb_msg_read_error);
  40. } else {
  41. size = len;
  42. if (len > SRC_BUF_SIZE)
  43. size = SRC_BUF_SIZE;
  44. }
  45. if (!size)
  46. break;
  47. // encode the buffer we just read in
  48. bb_uuencode(dst_buf, src_buf, size, bb_uuenc_tbl_base64);
  49. if (fname) {
  50. xwrite(STDOUT_FILENO, "\r\n", 2);
  51. } else {
  52. src_buf += size;
  53. len -= size;
  54. }
  55. xwrite(STDOUT_FILENO, dst_buf, 4 * ((size + 2) / 3));
  56. }
  57. if (fname)
  58. close(fd);
  59. #undef src_buf
  60. #undef len
  61. }
  62. struct globals {
  63. pid_t helper_pid;
  64. unsigned timeout;
  65. // arguments for SSL connection helper
  66. const char *xargs[9];
  67. // arguments for postprocess helper
  68. const char *fargs[3];
  69. };
  70. #define G (*ptr_to_globals)
  71. #define helper_pid (G.helper_pid)
  72. #define timeout (G.timeout )
  73. #define xargs (G.xargs )
  74. #define fargs (G.fargs )
  75. #define INIT_G() do { \
  76. SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
  77. xargs[0] = "openssl"; \
  78. xargs[1] = "s_client"; \
  79. xargs[2] = "-quiet"; \
  80. xargs[3] = "-connect"; \
  81. /*xargs[4] = "localhost";*/ \
  82. xargs[5] = "-tls1"; \
  83. xargs[6] = "-starttls"; \
  84. xargs[7] = "smtp"; \
  85. fargs[0] = "utf-8"; \
  86. } while (0)
  87. #define opt_connect (xargs[4])
  88. #define opt_after_connect (xargs[5])
  89. #define opt_charset (fargs[0])
  90. #define opt_subject (fargs[1])
  91. static void kill_helper(void)
  92. {
  93. // TODO!!!: is there more elegant way to terminate child on program failure?
  94. if (helper_pid > 0)
  95. kill(helper_pid, SIGTERM);
  96. }
  97. // generic signal handler
  98. static void signal_handler(int signo)
  99. {
  100. #define err signo
  101. if (SIGALRM == signo) {
  102. kill_helper();
  103. bb_error_msg_and_die("timed out");
  104. }
  105. // SIGCHLD. reap zombies
  106. if (wait_any_nohang(&err) > 0)
  107. if (WIFEXITED(err) && WEXITSTATUS(err))
  108. bb_error_msg_and_die("child exited (%d)", WEXITSTATUS(err));
  109. #undef err
  110. }
  111. static void launch_helper(const char **argv)
  112. {
  113. // setup vanilla unidirectional pipes interchange
  114. int idx;
  115. int pipes[4];
  116. xpipe(pipes);
  117. xpipe(pipes+2);
  118. helper_pid = vfork();
  119. if (helper_pid < 0)
  120. bb_perror_msg_and_die("vfork");
  121. idx = (!helper_pid) * 2;
  122. xdup2(pipes[idx], STDIN_FILENO);
  123. xdup2(pipes[3-idx], STDOUT_FILENO);
  124. if (ENABLE_FEATURE_CLEAN_UP)
  125. for (int i = 4; --i >= 0; )
  126. if (pipes[i] > STDOUT_FILENO)
  127. close(pipes[i]);
  128. if (!helper_pid) {
  129. // child: try to execute connection helper
  130. BB_EXECVP(*argv, (char **)argv);
  131. _exit(127);
  132. }
  133. // parent: check whether child is alive
  134. bb_signals(0
  135. + (1 << SIGCHLD)
  136. + (1 << SIGALRM)
  137. , signal_handler);
  138. signal_handler(SIGCHLD);
  139. // child seems OK -> parent goes on
  140. }
  141. static const char *command(const char *fmt, const char *param)
  142. {
  143. const char *msg = fmt;
  144. alarm(timeout);
  145. if (msg) {
  146. msg = xasprintf(fmt, param);
  147. printf("%s\r\n", msg);
  148. }
  149. fflush(stdout);
  150. return msg;
  151. }
  152. static int smtp_checkp(const char *fmt, const char *param, int code)
  153. {
  154. char *answer;
  155. const char *msg = command(fmt, param);
  156. // read stdin
  157. // if the string has a form \d\d\d- -- read next string. E.g. EHLO response
  158. // parse first bytes to a number
  159. // if code = -1 then just return this number
  160. // if code != -1 then checks whether the number equals the code
  161. // if not equal -> die saying msg
  162. while ((answer = xmalloc_fgetline(stdin)) != NULL)
  163. if (strlen(answer) <= 3 || '-' != answer[3])
  164. break;
  165. if (answer) {
  166. int n = atoi(answer);
  167. alarm(0);
  168. if (ENABLE_FEATURE_CLEAN_UP) {
  169. free(answer);
  170. }
  171. if (-1 == code || n == code) {
  172. return n;
  173. }
  174. }
  175. kill_helper();
  176. bb_error_msg_and_die("%s failed", msg);
  177. }
  178. static inline int smtp_check(const char *fmt, int code)
  179. {
  180. return smtp_checkp(fmt, NULL, code);
  181. }
  182. // strip argument of bad chars
  183. static char *sane(char *str)
  184. {
  185. char *s = str;
  186. char *p = s;
  187. while (*s) {
  188. if (isalnum(*s) || '_' == *s || '-' == *s || '.' == *s || '@' == *s) {
  189. *p++ = *s;
  190. }
  191. s++;
  192. }
  193. *p = '\0';
  194. return str;
  195. }
  196. #if ENABLE_FETCHMAIL
  197. static void pop3_checkr(const char *fmt, const char *param, char **ret)
  198. {
  199. const char *msg = command(fmt, param);
  200. char *answer = xmalloc_fgetline(stdin);
  201. if (answer && '+' == *answer) {
  202. alarm(0);
  203. if (ret)
  204. *ret = answer+4; // skip "+OK "
  205. else if (ENABLE_FEATURE_CLEAN_UP)
  206. free(answer);
  207. return;
  208. }
  209. kill_helper();
  210. bb_error_msg_and_die("%s failed", msg);
  211. }
  212. static inline void pop3_check(const char *fmt, const char *param)
  213. {
  214. pop3_checkr(fmt, param, NULL);
  215. }
  216. static void pop3_message(const char *filename)
  217. {
  218. int fd;
  219. char *answer;
  220. // create and open file filename
  221. // read stdin, copy to created file
  222. fd = xopen(filename, O_CREAT | O_WRONLY | O_TRUNC | O_EXCL);
  223. while ((answer = xmalloc_fgets_str(stdin, "\r\n")) != NULL) {
  224. char *s = answer;
  225. if ('.' == *answer) {
  226. if ('.' == answer[1])
  227. s++;
  228. else if ('\r' == answer[1] && '\n' == answer[2] && '\0' == answer[3])
  229. break;
  230. }
  231. xwrite(fd, s, strlen(s));
  232. free(answer);
  233. }
  234. close(fd);
  235. }
  236. #endif
  237. // NB: parse_url can modify url[] (despite const), but only if '@' is there
  238. static const char *parse_url(const char *url, const char **user, const char **pass)
  239. {
  240. // parse [user[:pass]@]host
  241. // return host
  242. char *s = strchr(url, '@');
  243. *user = *pass = NULL;
  244. if (s) {
  245. *s++ = '\0';
  246. *user = url;
  247. url = s;
  248. s = strchr(*user, ':');
  249. if (s) {
  250. *s++ = '\0';
  251. *pass = s;
  252. }
  253. }
  254. return url;
  255. }
  256. static void rcptto(const char *s)
  257. {
  258. smtp_checkp("RCPT TO:<%s>", s, 250);
  259. }
  260. int sendgetmail_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
  261. int sendgetmail_main(int argc UNUSED_PARAM, char **argv)
  262. {
  263. llist_t *opt_attachments = NULL;
  264. char *opt_from;
  265. const char *opt_user;
  266. const char *opt_pass;
  267. enum {
  268. OPT_w = 1 << 0, // network timeout
  269. OPT_H = 1 << 1, // [user:password@]server[:port]
  270. OPT_S = 1 << 2, // connect using openssl s_client helper
  271. OPTS_t = 1 << 3, // sendmail: read addresses from body
  272. OPTF_t = 1 << 3, // fetchmail: use "TOP" not "RETR"
  273. OPTS_s = 1 << 4, // sendmail: subject
  274. OPTF_z = 1 << 4, // fetchmail: delete from server
  275. OPTS_c = 1 << 5, // sendmail: assumed charset
  276. OPTS_a = 1 << 6, // sendmail: attachment(s)
  277. OPTS_i = 1 << 7, // sendmail: ignore lone dots in message body (implied)
  278. OPTS_N = 1 << 8, // sendmail: request notification
  279. OPTS_f = 1 << 9, // sendmail: sender address
  280. };
  281. const char *options;
  282. int opts;
  283. // init global variables
  284. INIT_G();
  285. // parse options, different option sets for sendmail and fetchmail
  286. // N.B. opt_after_connect hereafter is NULL if we are called as fetchmail
  287. // and is NOT NULL if we are called as sendmail
  288. if (!ENABLE_FETCHMAIL || 's' == applet_name[0]) {
  289. // SENDMAIL
  290. // save initial stdin since body is piped!
  291. xdup2(STDIN_FILENO, INITIAL_STDIN_FILENO);
  292. opt_complementary = "w+:a::";
  293. options = "w:H:St" "s:c:a:iN:f:";
  294. // body is pseudo attachment read from stdin
  295. llist_add_to_end(&opt_attachments, (char *)"-");
  296. } else {
  297. // FETCHMAIL
  298. opt_after_connect = NULL;
  299. opt_complementary = "-1:w+";
  300. options = "w:H:St" "z";
  301. }
  302. opts = getopt32(argv, options,
  303. &timeout /* -w */, &opt_connect /* -H */,
  304. &opt_subject, &opt_charset, &opt_attachments, NULL, &opt_from
  305. );
  306. //argc -= optind;
  307. argv += optind;
  308. // connect to server
  309. // host[:port] not specified ? -> use $HOSTNAME. no $HOSTNAME ? -> use localhost
  310. if (!(opts & OPT_H)) {
  311. opt_connect = getenv("HOSTNAME");
  312. if (!opt_connect)
  313. opt_connect = "127.0.0.1";
  314. }
  315. // fetch username and password, if any
  316. // NB: parse_url modifies opt_connect[] ONLY if '@' is there.
  317. // Thus "127.0.0.1" won't be modified, an is ok that it is RO.
  318. opt_connect = parse_url(opt_connect, &opt_user, &opt_pass);
  319. // bb_error_msg("H[%s] U[%s] P[%s]", opt_connect, opt_user, opt_pass);
  320. // username must be defined!
  321. if (!opt_user) {
  322. // N.B. IMHO getenv("USER") can be way easily spoofed!
  323. opt_user = bb_getpwuid(NULL, -1, getuid());
  324. }
  325. // SSL ordered? ->
  326. if (opts & OPT_S) {
  327. // ... use openssl helper
  328. launch_helper(xargs);
  329. // no SSL ordered? ->
  330. } else {
  331. // ... make plain connect
  332. int fd = create_and_connect_stream_or_die(opt_connect, 25);
  333. // make ourselves a simple IO filter
  334. // from now we know nothing about network :)
  335. xmove_fd(fd, STDIN_FILENO);
  336. xdup2(STDIN_FILENO, STDOUT_FILENO);
  337. }
  338. // are we sendmail?
  339. if (!ENABLE_FETCHMAIL || opt_after_connect)
  340. /***************************************************
  341. * SENDMAIL
  342. ***************************************************/
  343. {
  344. int code;
  345. char *boundary;
  346. const char *fmt;
  347. const char *p;
  348. char *q;
  349. llist_t *l;
  350. llist_t *headers = NULL;
  351. // got no sender address? -> use username as a resort
  352. if (!(opts & OPTS_f)) {
  353. char *domain = safe_getdomainname();
  354. opt_from = xasprintf("%s@%s", opt_user, domain);
  355. if (ENABLE_FEATURE_CLEAN_UP)
  356. free(domain);
  357. }
  358. // introduce to server
  359. // we didn't use SSL helper? ->
  360. if (!(opts & OPT_S)) {
  361. // ... wait for initial server OK
  362. smtp_check(NULL, 220);
  363. }
  364. // we should start with modern EHLO
  365. if (250 != smtp_checkp("EHLO %s", sane(opt_from), -1)) {
  366. smtp_checkp("HELO %s", opt_from, 250);
  367. }
  368. // set sender
  369. // NOTE: if password has not been specified
  370. // then no authentication is possible
  371. code = (opt_pass ? -1 : 250);
  372. // first try softly without authentication
  373. while (250 != smtp_checkp("MAIL FROM:<%s>", opt_from, code)) {
  374. // MAIL FROM failed -> authentication needed
  375. if (334 == smtp_check("AUTH LOGIN", -1)) {
  376. uuencode(NULL, opt_user); // opt_user != NULL
  377. smtp_check("", 334);
  378. uuencode(NULL, opt_pass);
  379. smtp_check("", 235);
  380. }
  381. // authenticated OK? -> retry to set sender
  382. // but this time die on failure!
  383. code = 250;
  384. }
  385. // recipients specified as arguments
  386. while (*argv) {
  387. // loose test on email address validity
  388. if (strchr(sane(*argv), '@')) {
  389. rcptto(sane(*argv));
  390. llist_add_to_end(&headers, xasprintf("To: %s", *argv));
  391. }
  392. argv++;
  393. }
  394. // if -t specified or no recipients specified -> enter all-included mode
  395. // i.e. scan stdin for To:, Cc:, Bcc:, and Subject: lines ...
  396. // ... and then use the rest of stdin as message body
  397. // N.B. subject read from body has priority
  398. // over that specified on command line.
  399. // recipients are merged
  400. // N.B. other headers are collected and will be dumped verbatim
  401. if (opts & OPTS_t || !headers) {
  402. // fetch recipients and (optionally) subject
  403. char *s;
  404. while ((s = xmalloc_reads(INITIAL_STDIN_FILENO, NULL, NULL)) != NULL) {
  405. if (0 == strncasecmp("To: ", s, 4) || 0 == strncasecmp("Cc: ", s, 4)) {
  406. rcptto(sane(s+4));
  407. llist_add_to_end(&headers, s);
  408. } else if (0 == strncasecmp("Bcc: ", s, 5)) {
  409. rcptto(sane(s+5));
  410. if (ENABLE_FEATURE_CLEAN_UP)
  411. free(s);
  412. // N.B. Bcc vanishes from headers!
  413. /* } else if (0 == strncmp("From: ", s, 6)) {
  414. opt_from = s+6;
  415. opts |= OPTS_f;
  416. */ } else if (0 == strncmp("Subject: ", s, 9)) {
  417. opt_subject = s+9;
  418. opts |= OPTS_s;
  419. } else if (s[0]) {
  420. // misc header
  421. llist_add_to_end(&headers, s);
  422. } else {
  423. free(s);
  424. break; // empty line
  425. }
  426. }
  427. }
  428. // enter "put message" mode
  429. smtp_check("DATA", 354);
  430. // put headers we could have preread with -t
  431. for (l = headers; l; l = l->link) {
  432. printf("%s\r\n", l->data);
  433. if (ENABLE_FEATURE_CLEAN_UP)
  434. free(l->data);
  435. }
  436. // put address header
  437. printf("From: %s\r\n", opt_from);
  438. // put encoded subject
  439. if (opts & OPTS_c)
  440. sane((char *)opt_charset);
  441. if (opts & OPTS_s) {
  442. printf("Subject: =?%s?B?", opt_charset);
  443. uuencode(NULL, opt_subject);
  444. printf("?=\r\n");
  445. }
  446. // put notification
  447. if (opts & OPTS_N)
  448. printf("Disposition-Notification-To: %s\r\n", opt_from);
  449. // make a random string -- it will delimit message parts
  450. srand(monotonic_us());
  451. boundary = xasprintf("%d-%d-%d", rand(), rand(), rand());
  452. // put common headers and body start
  453. printf(
  454. "Message-ID: <%s>\r\n"
  455. "Mime-Version: 1.0\r\n"
  456. "%smultipart/mixed; boundary=\"%s\"\r\n"
  457. , boundary
  458. , "Content-Type: "
  459. , boundary
  460. );
  461. // put body + attachment(s)
  462. // N.B. all these weird things just to be tiny
  463. // by reusing string patterns!
  464. fmt =
  465. "\r\n--%s\r\n"
  466. "%stext/plain; charset=%s\r\n"
  467. "%s%s\r\n"
  468. "%s"
  469. ;
  470. p = opt_charset;
  471. q = (char *)"";
  472. l = opt_attachments;
  473. while (l) {
  474. printf(
  475. fmt
  476. , boundary
  477. , "Content-Type: "
  478. , p
  479. , "Content-Disposition: inline"
  480. , q
  481. , "Content-Transfer-Encoding: base64\r\n"
  482. );
  483. p = "";
  484. fmt =
  485. "\r\n--%s\r\n"
  486. "%sapplication/octet-stream%s\r\n"
  487. "%s; filename=\"%s\"\r\n"
  488. "%s"
  489. ;
  490. uuencode(l->data, NULL);
  491. l = l->link;
  492. if (l)
  493. q = bb_get_last_path_component_strip(l->data);
  494. }
  495. // put message terminator
  496. printf("\r\n--%s--\r\n" "\r\n", boundary);
  497. // leave "put message" mode
  498. smtp_check(".", 250);
  499. // ... and say goodbye
  500. smtp_check("QUIT", 221);
  501. }
  502. #if ENABLE_FETCHMAIL
  503. /***************************************************
  504. * FETCHMAIL
  505. ***************************************************/
  506. else {
  507. char *buf;
  508. unsigned nmsg;
  509. char *hostname;
  510. pid_t pid;
  511. // cache fetch command:
  512. // TOP will return only the headers
  513. // RETR will dump the whole message
  514. const char *retr = (opts & OPTF_t) ? "TOP %u 0" : "RETR %u";
  515. // goto maildir
  516. xchdir(*argv++);
  517. // cache postprocess program
  518. *fargs = *argv;
  519. // authenticate
  520. // password is mandatory
  521. if (!opt_pass) {
  522. bb_error_msg_and_die("no password");
  523. }
  524. // get server greeting
  525. pop3_checkr(NULL, NULL, &buf);
  526. // server supports APOP?
  527. if ('<' == *buf) {
  528. md5_ctx_t md5;
  529. // yes! compose <stamp><password>
  530. char *s = strchr(buf, '>');
  531. if (s)
  532. strcpy(s+1, opt_pass);
  533. s = buf;
  534. // get md5 sum of <stamp><password>
  535. md5_begin(&md5);
  536. md5_hash(s, strlen(s), &md5);
  537. md5_end(s, &md5);
  538. // NOTE: md5 struct contains enough space
  539. // so we reuse md5 space instead of xzalloc(16*2+1)
  540. #define md5_hex ((uint8_t *)&md5)
  541. // uint8_t *md5_hex = (uint8_t *)&md5;
  542. *bin2hex((char *)md5_hex, s, 16) = '\0';
  543. // APOP
  544. s = xasprintf("%s %s", opt_user, md5_hex);
  545. #undef md5_hex
  546. pop3_check("APOP %s", s);
  547. if (ENABLE_FEATURE_CLEAN_UP) {
  548. free(s);
  549. free(buf-4); // buf is "+OK " away from malloc'ed string
  550. }
  551. // server ignores APOP -> use simple text authentication
  552. } else {
  553. // USER
  554. pop3_check("USER %s", opt_user);
  555. // PASS
  556. pop3_check("PASS %s", opt_pass);
  557. }
  558. // get mailbox statistics
  559. pop3_checkr("STAT", NULL, &buf);
  560. // prepare message filename suffix
  561. hostname = safe_gethostname();
  562. pid = getpid();
  563. // get messages counter
  564. // NOTE: we don't use xatou(buf) since buf is "nmsg nbytes"
  565. // we only need nmsg and atoi is just exactly what we need
  566. // if atoi fails to convert buf into number it returns 0
  567. // in this case the following loop simply will not be executed
  568. nmsg = atoi(buf);
  569. if (ENABLE_FEATURE_CLEAN_UP)
  570. free(buf-4); // buf is "+OK " away from malloc'ed string
  571. // loop through messages
  572. for (; nmsg; nmsg--) {
  573. // generate unique filename
  574. char *filename = xasprintf("tmp/%llu.%u.%s",
  575. monotonic_us(), (unsigned)pid, hostname);
  576. char *target;
  577. int rc;
  578. // retrieve message in ./tmp/
  579. pop3_check(retr, (const char *)(ptrdiff_t)nmsg);
  580. pop3_message(filename);
  581. // delete message from server
  582. if (opts & OPTF_z)
  583. pop3_check("DELE %u", (const char*)(ptrdiff_t)nmsg);
  584. // run postprocessing program
  585. if (*fargs) {
  586. fargs[1] = filename;
  587. rc = wait4pid(spawn((char **)fargs));
  588. if (99 == rc)
  589. break;
  590. if (1 == rc)
  591. goto skip;
  592. }
  593. // atomically move message to ./new/
  594. target = xstrdup(filename);
  595. strncpy(target, "new", 3);
  596. // ... or just stop receiving on error
  597. if (rename_or_warn(filename, target))
  598. break;
  599. free(target);
  600. skip:
  601. free(filename);
  602. }
  603. // Bye
  604. pop3_check("QUIT", NULL);
  605. }
  606. #endif // ENABLE_FETCHMAIL
  607. return 0;
  608. }