Add SMTP test.
* examples/mta.c: Handle -bD option. Detach from the controlling terminal if -bd is given. Print pid and port number in this case. * testsuite/smtpsend.c: Fix handling of the trace= option. * testsuite/Makefile.am: Add new tests. * testsuite/smtp-msg.at: New test case. * testsuite/smtp-str.at: New test case. * testsuite/testsuite.at: Include new test cases.
Showing
6 changed files
with
258 additions
and
38 deletions
... | @@ -27,12 +27,20 @@ | ... | @@ -27,12 +27,20 @@ |
27 | recipients. | 27 | recipients. |
28 | 28 | ||
29 | 2. mta -bd [-p port] | 29 | 2. mta -bd [-p port] |
30 | mta -bD [-p port] | ||
30 | 31 | ||
31 | Operates as daemon. If port is given, mta will listen on that port. | 32 | Operates as daemon. If port is given, mta will listen on that port. |
32 | Otherwise, it will use the first free port in the range 1024-65535. | 33 | Otherwise, it will use the first free port in the range 1024-65535. |
33 | In this case, mta prints the port number on the stdout, prior to | 34 | If the -bd option is given, mta switches to the background and prints |
34 | starting operation. Notice, that in this mode mta does not disconnect | 35 | its PID and port number on two separate lines on the stdout. It then |
35 | itself from the controlling terminal, it always stays on the foreground. | 36 | listens for incoming connections for no more than 60 seconds. |
37 | |||
38 | If the -bD option is given, the utility prints the port number and | ||
39 | listens for incoming connections not detaching itself from the controlling | ||
40 | terminal. | ||
41 | |||
42 | In any case, at most one connection is served, after which the utility | ||
43 | terminates. | ||
36 | 44 | ||
37 | Environment variables: | 45 | Environment variables: |
38 | 46 | ||
... | @@ -66,12 +74,13 @@ | ... | @@ -66,12 +74,13 @@ |
66 | FILE *diag = NULL; /* diagnostic output */ | 74 | FILE *diag = NULL; /* diagnostic output */ |
67 | int smtp_mode; /* Operate in smtp mode */ | 75 | int smtp_mode; /* Operate in smtp mode */ |
68 | int port = 0; /* Port number (for smtp mode) */ | 76 | int port = 0; /* Port number (for smtp mode) */ |
77 | int foreground = 0; /* Stay in the foreground (smtp mode) */ | ||
69 | char *from_person = NULL; /* Set the name of the `from' person */ | 78 | char *from_person = NULL; /* Set the name of the `from' person */ |
70 | int read_recipients = 0; /* Read the message for recipients */ | 79 | int read_recipients = 0; /* Read the message for recipients */ |
71 | int dot = 1; /* Message is terminated by a lone dot on a line */ | 80 | int dot = 1; /* Message is terminated by a lone dot on a line */ |
72 | 81 | ||
73 | mu_address_t recipients = NULL; | 82 | mu_address_t recipients = NULL; |
74 | char *progname; | 83 | |
75 | /* FIXME: If finalize_option is set, mta should try to finalize | 84 | /* FIXME: If finalize_option is set, mta should try to finalize |
76 | received messages the way sendmail does, i.e. to add To: or | 85 | received messages the way sendmail does, i.e. to add To: or |
77 | Cc: headers, if they are missing, etc. The code to do so is | 86 | Cc: headers, if they are missing, etc. The code to do so is |
... | @@ -95,9 +104,7 @@ main (int argc, char **argv) | ... | @@ -95,9 +104,7 @@ main (int argc, char **argv) |
95 | int c, status; | 104 | int c, status; |
96 | char *domain; | 105 | char *domain; |
97 | 106 | ||
98 | progname = strrchr (argv[0], '/'); | 107 | mu_set_program_name (argv[0]); |
99 | if (!progname) | ||
100 | progname = argv[0]; | ||
101 | 108 | ||
102 | while ((c = getopt (argc, argv, "b:f:p:to:")) != EOF) | 109 | while ((c = getopt (argc, argv, "b:f:p:to:")) != EOF) |
103 | { | 110 | { |
... | @@ -110,6 +117,11 @@ main (int argc, char **argv) | ... | @@ -110,6 +117,11 @@ main (int argc, char **argv) |
110 | smtp_mode = 1; | 117 | smtp_mode = 1; |
111 | break; | 118 | break; |
112 | 119 | ||
120 | case 'D': | ||
121 | smtp_mode = 1; | ||
122 | foreground = 1; | ||
123 | break; | ||
124 | |||
113 | default: | 125 | default: |
114 | /*FIXME*/; | 126 | /*FIXME*/; |
115 | } | 127 | } |
... | @@ -153,13 +165,13 @@ main (int argc, char **argv) | ... | @@ -153,13 +165,13 @@ main (int argc, char **argv) |
153 | diag = fopen (name, mode); | 165 | diag = fopen (name, mode); |
154 | if (!diag) | 166 | if (!diag) |
155 | { | 167 | { |
156 | mu_error ("%s: can't open diagnostic output: %s", | 168 | mu_error ("can't open diagnostic output %s: %s", |
157 | progname, name); | 169 | name, mu_strerror (errno)); |
158 | return 1; | 170 | return 1; |
159 | } | 171 | } |
160 | } | 172 | } |
161 | else | 173 | else |
162 | diag = stdout; | 174 | diag = stderr; |
163 | } | 175 | } |
164 | 176 | ||
165 | register_handlers (); | 177 | register_handlers (); |
... | @@ -226,7 +238,7 @@ make_tmp (mu_stream_t in) | ... | @@ -226,7 +238,7 @@ make_tmp (mu_stream_t in) |
226 | const char *from = from_address (); | 238 | const char *from = from_address (); |
227 | if (!from) | 239 | if (!from) |
228 | { | 240 | { |
229 | mu_error ("%s: can't determine sender address", progname); | 241 | mu_error ("can't determine sender address"); |
230 | exit (EX_NOUSER); | 242 | exit (EX_NOUSER); |
231 | } | 243 | } |
232 | 244 | ||
... | @@ -301,7 +313,7 @@ address_email_string (mu_address_t addr) | ... | @@ -301,7 +313,7 @@ address_email_string (mu_address_t addr) |
301 | value = malloc (length + 1); | 313 | value = malloc (length + 1); |
302 | if (!value) | 314 | if (!value) |
303 | { | 315 | { |
304 | mu_error ("%s: not enough memory", progname); | 316 | mu_error ("not enough memory"); |
305 | return NULL; | 317 | return NULL; |
306 | } | 318 | } |
307 | p = value; | 319 | p = value; |
... | @@ -390,7 +402,7 @@ message_finalize (mu_message_t msg, int warn) | ... | @@ -390,7 +402,7 @@ message_finalize (mu_message_t msg, int warn) |
390 | sizeof (SENDER_WARNING)); | 402 | sizeof (SENDER_WARNING)); |
391 | if (warn == NULL) | 403 | if (warn == NULL) |
392 | { | 404 | { |
393 | mu_error ("%s: not enough memory", progname); | 405 | mu_error ("not enough memory"); |
394 | return 1; | 406 | return 1; |
395 | } | 407 | } |
396 | sprintf (warn, "%s %s", pwd->pw_name, SENDER_WARNING); | 408 | sprintf (warn, "%s %s", pwd->pw_name, SENDER_WARNING); |
... | @@ -406,7 +418,7 @@ message_finalize (mu_message_t msg, int warn) | ... | @@ -406,7 +418,7 @@ message_finalize (mu_message_t msg, int warn) |
406 | { | 418 | { |
407 | if (add_recipient (value)) | 419 | if (add_recipient (value)) |
408 | { | 420 | { |
409 | mu_error ("%s: bad address %s", progname, value); | 421 | mu_error ("bad address %s", value); |
410 | return 1; | 422 | return 1; |
411 | } | 423 | } |
412 | free (value); | 424 | free (value); |
... | @@ -416,7 +428,7 @@ message_finalize (mu_message_t msg, int warn) | ... | @@ -416,7 +428,7 @@ message_finalize (mu_message_t msg, int warn) |
416 | { | 428 | { |
417 | if (add_recipient (value)) | 429 | if (add_recipient (value)) |
418 | { | 430 | { |
419 | mu_error ("%s: bad address %s", progname, value); | 431 | mu_error ("bad address %s", value); |
420 | return 1; | 432 | return 1; |
421 | } | 433 | } |
422 | free (value); | 434 | free (value); |
... | @@ -427,7 +439,7 @@ message_finalize (mu_message_t msg, int warn) | ... | @@ -427,7 +439,7 @@ message_finalize (mu_message_t msg, int warn) |
427 | { | 439 | { |
428 | if (add_recipient (value)) | 440 | if (add_recipient (value)) |
429 | { | 441 | { |
430 | mu_error ("%s: bad address %s", progname, value); | 442 | mu_error ("bad address %s", value); |
431 | return 1; | 443 | return 1; |
432 | } | 444 | } |
433 | free (value); | 445 | free (value); |
... | @@ -443,8 +455,8 @@ message_finalize (mu_message_t msg, int warn) | ... | @@ -443,8 +455,8 @@ message_finalize (mu_message_t msg, int warn) |
443 | c = mu_address_sget_printable (recipients, &sptr); | 455 | c = mu_address_sget_printable (recipients, &sptr); |
444 | if (c) | 456 | if (c) |
445 | { | 457 | { |
446 | mu_error ("%s: mu_address_sget_printable failure: %s", | 458 | mu_error ("mu_address_sget_printable failure: %s", |
447 | progname, mu_strerror (c)); | 459 | mu_strerror (c)); |
448 | return 1; | 460 | return 1; |
449 | } | 461 | } |
450 | mu_header_set_value (header, MU_HEADER_TO, sptr, 1); | 462 | mu_header_set_value (header, MU_HEADER_TO, sptr, 1); |
... | @@ -463,7 +475,7 @@ mta_stdin (int argc, char **argv) | ... | @@ -463,7 +475,7 @@ mta_stdin (int argc, char **argv) |
463 | { | 475 | { |
464 | if (add_recipient (argv[c])) | 476 | if (add_recipient (argv[c])) |
465 | { | 477 | { |
466 | mu_error ("%s: bad address %s", progname, argv[c]); | 478 | mu_error ("bad address %s", argv[c]); |
467 | return 1; | 479 | return 1; |
468 | } | 480 | } |
469 | } | 481 | } |
... | @@ -483,7 +495,7 @@ mta_stdin (int argc, char **argv) | ... | @@ -483,7 +495,7 @@ mta_stdin (int argc, char **argv) |
483 | 495 | ||
484 | if (!recipients) | 496 | if (!recipients) |
485 | { | 497 | { |
486 | mu_error ("%s: Recipient names must be specified", progname); | 498 | mu_error ("recipient names must be specified"); |
487 | return 1; | 499 | return 1; |
488 | } | 500 | } |
489 | 501 | ||
... | @@ -501,7 +513,7 @@ smtp_reply (mu_stream_t str, int code, char *fmt, ...) | ... | @@ -501,7 +513,7 @@ smtp_reply (mu_stream_t str, int code, char *fmt, ...) |
501 | va_start (ap, fmt); | 513 | va_start (ap, fmt); |
502 | mu_stream_vprintf (str, fmt, ap); | 514 | mu_stream_vprintf (str, fmt, ap); |
503 | va_end (ap); | 515 | va_end (ap); |
504 | mu_stream_printf (str, "\r\n"); | 516 | mu_stream_printf (str, "\n"); |
505 | } | 517 | } |
506 | 518 | ||
507 | #define STATE_INIT 0 | 519 | #define STATE_INIT 0 |
... | @@ -567,10 +579,18 @@ smtp (mu_stream_t str) | ... | @@ -567,10 +579,18 @@ smtp (mu_stream_t str) |
567 | smtp_reply (str, 220, "Ready"); | 579 | smtp_reply (str, 220, "Ready"); |
568 | for (state = STATE_INIT; state != STATE_QUIT; ) | 580 | for (state = STATE_INIT; state != STATE_QUIT; ) |
569 | { | 581 | { |
582 | int rc; | ||
570 | int kw; | 583 | int kw; |
571 | size_t len; | 584 | size_t len; |
572 | 585 | ||
573 | if (mu_stream_getline (str, &buf, &size, &len) || len == 0) | 586 | rc = mu_stream_getline (str, &buf, &size, &len); |
587 | if (rc) | ||
588 | { | ||
589 | mu_diag_funcall (MU_DIAG_ERROR, "mu_stream_getline", NULL, rc); | ||
590 | exit (EX_PROTOCOL); | ||
591 | } | ||
592 | |||
593 | if (len == 0) | ||
574 | exit (EX_PROTOCOL); | 594 | exit (EX_PROTOCOL); |
575 | 595 | ||
576 | if (mu_wordsplit (buf, &ws, wsflags)) | 596 | if (mu_wordsplit (buf, &ws, wsflags)) |
... | @@ -702,8 +722,8 @@ smtp (mu_stream_t str) | ... | @@ -702,8 +722,8 @@ smtp (mu_stream_t str) |
702 | mu_message_t msg; | 722 | mu_message_t msg; |
703 | int rc; | 723 | int rc; |
704 | 724 | ||
705 | rc = mu_filter_create (&flt, str, "CRLFDOT", MU_FILTER_DECODE, | 725 | rc = mu_filter_create (&flt, str, "DOT", MU_FILTER_DECODE, |
706 | MU_STREAM_READ|MU_STREAM_WRTHRU); | 726 | MU_STREAM_READ); |
707 | if (rc) | 727 | if (rc) |
708 | { | 728 | { |
709 | mu_diag_funcall (MU_DIAG_ERROR, "mu_filter_create", | 729 | mu_diag_funcall (MU_DIAG_ERROR, "mu_filter_create", |
... | @@ -738,17 +758,22 @@ smtp (mu_stream_t str) | ... | @@ -738,17 +758,22 @@ smtp (mu_stream_t str) |
738 | } | 758 | } |
739 | } | 759 | } |
740 | 760 | ||
761 | #ifndef INADDR_LOOPBACK | ||
762 | # define INADDR_LOOPBACK 0x7f000001 | ||
763 | #endif | ||
764 | |||
741 | int | 765 | int |
742 | mta_smtp (int argc, char **argv) | 766 | mta_smtp (int argc, char **argv) |
743 | { | 767 | { |
744 | int on = 1; | 768 | int on = 1; |
745 | struct sockaddr_in address; | 769 | struct sockaddr_in address; |
746 | int fd; | 770 | int fd; |
771 | pid_t pid; | ||
747 | 772 | ||
748 | fd = socket (PF_INET, SOCK_STREAM, 0); | 773 | fd = socket (PF_INET, SOCK_STREAM, 0); |
749 | if (fd < 0) | 774 | if (fd < 0) |
750 | { | 775 | { |
751 | mu_error ("%s: socket: %s", progname, strerror (errno)); | 776 | mu_error ("socket: %s", mu_strerror (errno)); |
752 | return 1; | 777 | return 1; |
753 | } | 778 | } |
754 | 779 | ||
... | @@ -756,7 +781,7 @@ mta_smtp (int argc, char **argv) | ... | @@ -756,7 +781,7 @@ mta_smtp (int argc, char **argv) |
756 | 781 | ||
757 | memset (&address, 0, sizeof (address)); | 782 | memset (&address, 0, sizeof (address)); |
758 | address.sin_family = AF_INET; | 783 | address.sin_family = AF_INET; |
759 | address.sin_addr.s_addr = INADDR_ANY; | 784 | address.sin_addr.s_addr = htonl (INADDR_LOOPBACK); |
760 | 785 | ||
761 | if (port) | 786 | if (port) |
762 | { | 787 | { |
... | @@ -764,7 +789,7 @@ mta_smtp (int argc, char **argv) | ... | @@ -764,7 +789,7 @@ mta_smtp (int argc, char **argv) |
764 | if (bind (fd, (struct sockaddr *) &address, sizeof (address)) < 0) | 789 | if (bind (fd, (struct sockaddr *) &address, sizeof (address)) < 0) |
765 | { | 790 | { |
766 | close (fd); | 791 | close (fd); |
767 | mu_error ("%s: bind: %s", progname, strerror(errno)); | 792 | mu_error ("bind: %s", mu_strerror (errno)); |
768 | return 1; | 793 | return 1; |
769 | } | 794 | } |
770 | } | 795 | } |
... | @@ -777,8 +802,7 @@ mta_smtp (int argc, char **argv) | ... | @@ -777,8 +802,7 @@ mta_smtp (int argc, char **argv) |
777 | { | 802 | { |
778 | if (++port >= 65535) | 803 | if (++port >= 65535) |
779 | { | 804 | { |
780 | mu_error ("%s: can't bind socket: all ports in use?", | 805 | mu_error ("can't bind socket: all ports in use?"); |
781 | progname); | ||
782 | return 1; | 806 | return 1; |
783 | } | 807 | } |
784 | address.sin_port = htons (port); | 808 | address.sin_port = htons (port); |
... | @@ -788,8 +812,30 @@ mta_smtp (int argc, char **argv) | ... | @@ -788,8 +812,30 @@ mta_smtp (int argc, char **argv) |
788 | } | 812 | } |
789 | 813 | ||
790 | listen (fd, 5); | 814 | listen (fd, 5); |
815 | if (!foreground) | ||
816 | { | ||
817 | pid = fork (); | ||
818 | if (pid == -1) | ||
819 | { | ||
820 | mu_error ("fork: %s", mu_strerror (errno)); | ||
821 | return 1; | ||
822 | } | ||
823 | if (pid) | ||
824 | { | ||
825 | /* Master process. */ | ||
826 | printf ("%lu\n", (unsigned long) pid); | ||
791 | printf ("%d\n", port); | 827 | printf ("%d\n", port); |
828 | return 0; | ||
829 | } | ||
830 | } | ||
831 | else | ||
832 | printf ("%d\n", port); | ||
833 | |||
834 | /* Child */ | ||
792 | fclose (stdout); | 835 | fclose (stdout); |
836 | if (!foreground) | ||
837 | alarm (60); | ||
838 | |||
793 | while (1) | 839 | while (1) |
794 | { | 840 | { |
795 | fd_set rfds; | 841 | fd_set rfds; |
... | @@ -797,7 +843,7 @@ mta_smtp (int argc, char **argv) | ... | @@ -797,7 +843,7 @@ mta_smtp (int argc, char **argv) |
797 | int sfd, status; | 843 | int sfd, status; |
798 | socklen_t len; | 844 | socklen_t len; |
799 | int rc; | 845 | int rc; |
800 | mu_stream_t str; | 846 | mu_stream_t str, istream, ostream, flt; |
801 | 847 | ||
802 | FD_ZERO (&rfds); | 848 | FD_ZERO (&rfds); |
803 | FD_SET (fd, &rfds); | 849 | FD_SET (fd, &rfds); |
... | @@ -807,22 +853,61 @@ mta_smtp (int argc, char **argv) | ... | @@ -807,22 +853,61 @@ mta_smtp (int argc, char **argv) |
807 | { | 853 | { |
808 | if (errno == EINTR) | 854 | if (errno == EINTR) |
809 | continue; | 855 | continue; |
810 | mu_error ("%s: select: %s", progname, strerror (errno)); | 856 | mu_error ("select: %s", mu_strerror (errno)); |
811 | return 1; | 857 | return 1; |
812 | } | 858 | } |
813 | 859 | ||
814 | len = sizeof (his_addr); | 860 | len = sizeof (his_addr); |
815 | if ((sfd = accept (fd, (struct sockaddr *)&his_addr, &len)) < 0) | 861 | if ((sfd = accept (fd, (struct sockaddr *)&his_addr, &len)) < 0) |
816 | { | 862 | { |
817 | mu_error ("%s: accept: %s", progname, strerror (errno)); | 863 | mu_error ("accept: %s", mu_strerror (errno)); |
818 | return 1; | 864 | return 1; |
819 | } | 865 | } |
820 | 866 | ||
821 | rc = mu_fd_stream_create (&str, NULL, sfd, MU_STREAM_RDWR); | 867 | rc = mu_stdio_stream_create (&istream, sfd, MU_STREAM_READ); |
822 | if (rc) | 868 | if (rc) |
823 | { | 869 | { |
824 | mu_diag_funcall (MU_DIAG_ERROR, "mu_fd_stream_create", NULL, rc); | 870 | mu_diag_funcall (MU_DIAG_ERROR, "mu_stdio_stream_create", |
825 | break; | 871 | "MU_STREAM_READ", rc); |
872 | return 1; | ||
873 | } | ||
874 | mu_stream_set_buffer (istream, mu_buffer_line, 0); | ||
875 | rc = mu_filter_create (&flt, istream, "CRLF", MU_FILTER_DECODE, | ||
876 | MU_STREAM_READ); | ||
877 | mu_stream_unref (istream); | ||
878 | if (rc) | ||
879 | { | ||
880 | mu_diag_funcall (MU_DIAG_ERROR, "mu_filter_create", | ||
881 | "CRLF,MU_FILTER_DECODE", rc); | ||
882 | return 1; | ||
883 | } | ||
884 | mu_stream_set_buffer (flt, mu_buffer_line, 0); | ||
885 | istream = flt; | ||
886 | |||
887 | rc = mu_stdio_stream_create (&ostream, sfd, MU_STREAM_WRITE); | ||
888 | if (rc) | ||
889 | { | ||
890 | mu_diag_funcall (MU_DIAG_ERROR, "mu_stdio_stream_create", | ||
891 | "MU_STREAM_WRITE", rc); | ||
892 | return 1; | ||
893 | } | ||
894 | mu_stream_set_buffer (ostream, mu_buffer_line, 0); | ||
895 | rc = mu_filter_create (&flt, ostream, "CRLF", MU_FILTER_ENCODE, | ||
896 | MU_STREAM_WRITE); | ||
897 | mu_stream_unref (ostream); | ||
898 | if (rc) | ||
899 | { | ||
900 | mu_diag_funcall (MU_DIAG_ERROR, "mu_filter_create", | ||
901 | "CRLF,MU_FILTER_ENCODE", rc); | ||
902 | return 1; | ||
903 | } | ||
904 | mu_stream_set_buffer (flt, mu_buffer_line, 0); | ||
905 | ostream = flt; | ||
906 | rc = mu_iostream_create (&str, istream, ostream); | ||
907 | if (rc) | ||
908 | { | ||
909 | mu_diag_funcall (MU_DIAG_ERROR, "mu_iostream_create", NULL, rc); | ||
910 | return 1; | ||
826 | } | 911 | } |
827 | mu_stream_set_buffer (str, mu_buffer_line, 0); | 912 | mu_stream_set_buffer (str, mu_buffer_line, 0); |
828 | smtp (str); | 913 | smtp (str); | ... | ... |
testsuite/smtp-msg.at
0 → 100644
1 | # This file is part of GNU Mailutils. -*- Autotest -*- | ||
2 | # Copyright (C) 2011 Free Software Foundation, Inc. | ||
3 | # | ||
4 | # GNU Mailutils is free software; you can redistribute it and/or | ||
5 | # modify it under the terms of the GNU General Public License as | ||
6 | # published by the Free Software Foundation; either version 3, or (at | ||
7 | # your option) any later version. | ||
8 | # | ||
9 | # GNU Mailutils is distributed in the hope that it will be useful, but | ||
10 | # WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | # General Public License for more details. | ||
13 | # | ||
14 | # You should have received a copy of the GNU General Public License | ||
15 | # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. | ||
16 | |||
17 | AT_SETUP([smtp send from message]) | ||
18 | AT_KEYWORDS([smtp-msg]) | ||
19 | |||
20 | AT_DATA([msg],[dnl | ||
21 | From: mailutils@localhost | ||
22 | To: gray@example.org | ||
23 | Subject: SMTP test | ||
24 | |||
25 | Omnis enim res, quae dando non deficit, | ||
26 | dum habetur et non datur, nondum habetur, | ||
27 | quomodo habenda est. | ||
28 | ]) | ||
29 | |||
30 | AT_CHECK([ | ||
31 | MTA_DIAG=`pwd`/mta.diag | ||
32 | export MTA_DIAG | ||
33 | p=`$abs_top_builddir/examples/mta -bd` | ||
34 | test $? -eq 0 || AT_SKIP_TEST | ||
35 | set -- $p | ||
36 | # $1 - pid, $2 - port | ||
37 | smtpsend localhost port=$2 \ | ||
38 | from=mailutils@mailutils.org\ | ||
39 | rcpt=gray@example.org\ | ||
40 | domain=mailutils.org\ | ||
41 | input=msg | ||
42 | kill $1 | ||
43 | cat mta.diag | ||
44 | ], | ||
45 | [0], | ||
46 | [ENVELOPE FROM: <mailutils@mailutils.org> | ||
47 | ENVELOPE TO: <gray@example.org> | ||
48 | 0: From: mailutils@localhost | ||
49 | 1: To: gray@example.org | ||
50 | 2: Subject: SMTP test | ||
51 | 3: | ||
52 | 4: Omnis enim res, quae dando non deficit, | ||
53 | 5: dum habetur et non datur, nondum habetur, | ||
54 | 6: quomodo habenda est. | ||
55 | 7: | ||
56 | END OF MESSAGE | ||
57 | ]) | ||
58 | |||
59 | AT_CLEANUP | ||
60 | |||
61 | |||
... | \ No newline at end of file | ... | \ No newline at end of file |
testsuite/smtp-str.at
0 → 100644
1 | # This file is part of GNU Mailutils. -*- Autotest -*- | ||
2 | # Copyright (C) 2011 Free Software Foundation, Inc. | ||
3 | # | ||
4 | # GNU Mailutils is free software; you can redistribute it and/or | ||
5 | # modify it under the terms of the GNU General Public License as | ||
6 | # published by the Free Software Foundation; either version 3, or (at | ||
7 | # your option) any later version. | ||
8 | # | ||
9 | # GNU Mailutils is distributed in the hope that it will be useful, but | ||
10 | # WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | # General Public License for more details. | ||
13 | # | ||
14 | # You should have received a copy of the GNU General Public License | ||
15 | # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. | ||
16 | |||
17 | AT_SETUP([smtp send from stream]) | ||
18 | AT_KEYWORDS([smtp-stream smtp-str]) | ||
19 | |||
20 | AT_DATA([msg],[dnl | ||
21 | From: mailutils@localhost | ||
22 | To: gray@example.org | ||
23 | Subject: SMTP test | ||
24 | |||
25 | Omnis enim res, quae dando non deficit, | ||
26 | dum habetur et non datur, nondum habetur, | ||
27 | quomodo habenda est. | ||
28 | ]) | ||
29 | |||
30 | AT_CHECK([ | ||
31 | MTA_DIAG=`pwd`/mta.diag | ||
32 | export MTA_DIAG | ||
33 | p=`$abs_top_builddir/examples/mta -bd` | ||
34 | test $? -eq 0 || AT_SKIP_TEST | ||
35 | set -- $p | ||
36 | # $1 - pid, $2 - port | ||
37 | smtpsend localhost port=$2 \ | ||
38 | from=mailutils@mailutils.org\ | ||
39 | rcpt=gray@example.org\ | ||
40 | domain=mailutils.org\ | ||
41 | raw=1\ | ||
42 | input=msg | ||
43 | kill $1 | ||
44 | cat mta.diag | ||
45 | ], | ||
46 | [0], | ||
47 | [ENVELOPE FROM: <mailutils@mailutils.org> | ||
48 | ENVELOPE TO: <gray@example.org> | ||
49 | 0: From: mailutils@localhost | ||
50 | 1: To: gray@example.org | ||
51 | 2: Subject: SMTP test | ||
52 | 3: | ||
53 | 4: Omnis enim res, quae dando non deficit, | ||
54 | 5: dum habetur et non datur, nondum habetur, | ||
55 | 6: quomodo habenda est. | ||
56 | 7: | ||
57 | END OF MESSAGE | ||
58 | ]) | ||
59 | |||
60 | AT_CLEANUP | ||
61 | |||
62 | |||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -120,10 +120,16 @@ main (int argc, char **argv) | ... | @@ -120,10 +120,16 @@ main (int argc, char **argv) |
120 | if (mu_isdigit (arg[0])) | 120 | if (mu_isdigit (arg[0])) |
121 | mu_smtp_trace (smtp, atoi (argv[i] + 6) ? | 121 | mu_smtp_trace (smtp, atoi (argv[i] + 6) ? |
122 | MU_SMTP_TRACE_SET : MU_SMTP_TRACE_CLR); | 122 | MU_SMTP_TRACE_SET : MU_SMTP_TRACE_CLR); |
123 | else if (strcmp (arg, "secure") == 0) | 123 | else |
124 | mu_smtp_trace_mask (smtp, MU_SMTP_TRACE_SET, MU_XSCRIPT_SECURE); | 124 | { |
125 | mu_smtp_trace (smtp, MU_SMTP_TRACE_SET); | ||
126 | if (strcmp (arg, "secure") == 0) | ||
127 | mu_smtp_trace_mask (smtp, MU_SMTP_TRACE_SET, | ||
128 | MU_XSCRIPT_SECURE); | ||
125 | else if (strcmp (arg, "payload") == 0) | 129 | else if (strcmp (arg, "payload") == 0) |
126 | mu_smtp_trace_mask (smtp, MU_SMTP_TRACE_SET, MU_XSCRIPT_PAYLOAD); | 130 | mu_smtp_trace_mask (smtp, MU_SMTP_TRACE_SET, |
131 | MU_XSCRIPT_PAYLOAD); | ||
132 | } | ||
127 | } | 133 | } |
128 | else if (strncmp (argv[i], "tls=", 4) == 0) | 134 | else if (strncmp (argv[i], "tls=", 4) == 0) |
129 | tls = atoi (argv[i] + 4); | 135 | tls = atoi (argv[i] + 4); | ... | ... |
... | @@ -32,5 +32,9 @@ m4_include([mbdel.at]) | ... | @@ -32,5 +32,9 @@ m4_include([mbdel.at]) |
32 | AT_BANNER(Folder mailbox removal) | 32 | AT_BANNER(Folder mailbox removal) |
33 | m4_include([fldel.at]) | 33 | m4_include([fldel.at]) |
34 | 34 | ||
35 | AT_BANNER(SMTP) | ||
36 | m4_include([smtp-msg.at]) | ||
37 | m4_include([smtp-str.at]) | ||
38 | |||
35 | AT_BANNER(Various) | 39 | AT_BANNER(Various) |
36 | m4_include([ufms.at]) | 40 | m4_include([ufms.at]) | ... | ... |
-
Please register or sign in to post a comment