1 /******************************************************************************
2 *
3 * Nagios check_smtp plugin
4 *
5 * License: GPL
6 * Copyright (c) 1999-2006 nagios-plugins team
7 *
8 * Last Modified: $Date$
9 *
10 * Description:
11 *
12 * This file contains the check_smtp plugin
13 *
14 * This plugin will attempt to open an SMTP connection with the host.
15 *
16 *
17 * License Information:
18 *
19 * This program is free software; you can redistribute it and/or modify
20 * it under the terms of the GNU General Public License as published by
21 * the Free Software Foundation; either version 2 of the License, or
22 * (at your option) any later version.
23 *
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details.
28 *
29 * You should have received a copy of the GNU General Public License
30 * along with this program; if not, write to the Free Software
31 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
32 *
33 *
34 * $Id$
35 *
36 ******************************************************************************/
38 const char *progname = "check_smtp";
39 const char *revision = "$Revision$";
40 const char *copyright = "2000-2006";
41 const char *email = "nagiosplug-devel@lists.sourceforge.net";
43 #include "common.h"
44 #include "netutils.h"
45 #include "utils.h"
47 #ifdef HAVE_SSL
48 int check_cert = FALSE;
49 int days_till_exp;
50 # define my_recv(buf, len) ((use_ssl && ssl_established) ? np_net_ssl_read(buf, len) : read(sd, buf, len))
51 # define my_send(buf, len) ((use_ssl && ssl_established) ? np_net_ssl_write(buf, len) : send(sd, buf, len, 0))
52 #else /* ifndef HAVE_SSL */
53 # define my_recv(buf, len) read(sd, buf, len)
54 # define my_send(buf, len) send(sd, buf, len, 0)
55 #endif
57 enum {
58 SMTP_PORT = 25
59 };
60 #define SMTP_EXPECT "220"
61 #define SMTP_HELO "HELO "
62 #define SMTP_EHLO "EHLO "
63 #define SMTP_QUIT "QUIT\r\n"
64 #define SMTP_STARTTLS "STARTTLS\r\n"
65 #define SMTP_AUTH_LOGIN "AUTH LOGIN\r\n"
67 #ifndef HOST_MAX_BYTES
68 #define HOST_MAX_BYTES 255
69 #endif
71 #define EHLO_SUPPORTS_STARTTLS 1
73 int process_arguments (int, char **);
74 int validate_arguments (void);
75 void print_help (void);
76 void print_usage (void);
77 int my_close(void);
79 #include "regex.h"
80 char regex_expect[MAX_INPUT_BUFFER] = "";
81 regex_t preg;
82 regmatch_t pmatch[10];
83 char timestamp[20] = "";
84 char errbuf[MAX_INPUT_BUFFER];
85 int cflags = REG_EXTENDED | REG_NOSUB | REG_NEWLINE;
86 int eflags = 0;
87 int errcode, excode;
89 int server_port = SMTP_PORT;
90 char *server_address = NULL;
91 char *server_expect = NULL;
92 int smtp_use_dummycmd = 0;
93 char *mail_command = NULL;
94 char *from_arg = NULL;
95 int ncommands=0;
96 int command_size=0;
97 int nresponses=0;
98 int response_size=0;
99 char **commands = NULL;
100 char **responses = NULL;
101 char *authtype = NULL;
102 char *authuser = NULL;
103 char *authpass = NULL;
104 int warning_time = 0;
105 int check_warning_time = FALSE;
106 int critical_time = 0;
107 int check_critical_time = FALSE;
108 int verbose = 0;
109 int use_ssl = FALSE;
110 short use_ehlo = FALSE;
111 short ssl_established = 0;
112 char *localhostname = NULL;
113 int sd;
114 char buffer[MAX_INPUT_BUFFER];
115 enum {
116 TCP_PROTOCOL = 1,
117 UDP_PROTOCOL = 2,
118 MAXBUF = 1024
119 };
121 /* written by lauri alanko */
122 static char *
123 base64 (const char *bin, size_t len)
124 {
126 char *buf = (char *) malloc ((len + 2) / 3 * 4 + 1);
127 size_t i = 0, j = 0;
129 char BASE64_END = '=';
130 char base64_table[64];
131 strncpy (base64_table, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", 64);
133 while (j < len - 2) {
134 buf[i++] = base64_table[bin[j] >> 2];
135 buf[i++] = base64_table[((bin[j] & 3) << 4) | (bin[j + 1] >> 4)];
136 buf[i++] = base64_table[((bin[j + 1] & 15) << 2) | (bin[j + 2] >> 6)];
137 buf[i++] = base64_table[bin[j + 2] & 63];
138 j += 3;
139 }
141 switch (len - j) {
142 case 1:
143 buf[i++] = base64_table[bin[j] >> 2];
144 buf[i++] = base64_table[(bin[j] & 3) << 4];
145 buf[i++] = BASE64_END;
146 buf[i++] = BASE64_END;
147 break;
148 case 2:
149 buf[i++] = base64_table[bin[j] >> 2];
150 buf[i++] = base64_table[((bin[j] & 3) << 4) | (bin[j + 1] >> 4)];
151 buf[i++] = base64_table[(bin[j + 1] & 15) << 2];
152 buf[i++] = BASE64_END;
153 break;
154 case 0:
155 break;
156 }
158 buf[i] = '\0';
159 return buf;
160 }
162 int
163 main (int argc, char **argv)
164 {
165 short supports_tls=FALSE;
166 int n = 0;
167 double elapsed_time;
168 long microsec;
169 int result = STATE_UNKNOWN;
170 char *cmd_str = NULL;
171 char *helocmd = NULL;
172 char *error_msg = NULL;
173 struct timeval tv;
175 setlocale (LC_ALL, "");
176 bindtextdomain (PACKAGE, LOCALEDIR);
177 textdomain (PACKAGE);
179 if (process_arguments (argc, argv) == ERROR)
180 usage4 (_("Could not parse arguments"));
182 /* initialize the HELO command with the localhostname */
183 if(! localhostname){
184 localhostname = malloc (HOST_MAX_BYTES);
185 if(!localhostname){
186 printf(_("malloc() failed!\n"));
187 return STATE_CRITICAL;
188 }
189 if(gethostname(localhostname, HOST_MAX_BYTES)){
190 printf(_("gethostname() failed!\n"));
191 return STATE_CRITICAL;
192 }
193 } else {
194 helocmd = localhostname;
195 }
196 if(use_ehlo)
197 asprintf (&helocmd, "%s%s%s", SMTP_EHLO, helocmd, "\r\n");
198 else
199 asprintf (&helocmd, "%s%s%s", SMTP_HELO, helocmd, "\r\n");
201 if (verbose)
202 printf("HELOCMD: %s", helocmd);
204 /* initialize the MAIL command with optional FROM command */
205 asprintf (&cmd_str, "%sFROM: %s%s", mail_command, from_arg, "\r\n");
207 if (verbose && smtp_use_dummycmd)
208 printf ("FROM CMD: %s", cmd_str);
210 /* initialize alarm signal handling */
211 (void) signal (SIGALRM, socket_timeout_alarm_handler);
213 /* set socket timeout */
214 (void) alarm (socket_timeout);
216 /* start timer */
217 gettimeofday (&tv, NULL);
219 /* try to connect to the host at the given port number */
220 result = my_tcp_connect (server_address, server_port, &sd);
222 if (result == STATE_OK) { /* we connected */
224 /* watch for the SMTP connection string and */
225 /* return a WARNING status if we couldn't read any data */
226 if (recv (sd, buffer, MAX_INPUT_BUFFER - 1, 0) == -1) {
227 printf (_("recv() failed\n"));
228 result = STATE_WARNING;
229 }
230 else {
231 if (verbose)
232 printf ("%s", buffer);
233 /* strip the buffer of carriage returns */
234 strip (buffer);
235 /* make sure we find the response we are looking for */
236 if (!strstr (buffer, server_expect)) {
237 if (server_port == SMTP_PORT)
238 printf (_("Invalid SMTP response received from host\n"));
239 else
240 printf (_("Invalid SMTP response received from host on port %d\n"),
241 server_port);
242 result = STATE_WARNING;
243 }
244 }
246 /* send the HELO/EHLO command */
247 send(sd, helocmd, strlen(helocmd), 0);
249 /* allow for response to helo command to reach us */
250 if(read (sd, buffer, MAXBUF - 1) < 0){
251 printf (_("recv() failed\n"));
252 return STATE_WARNING;
253 } else if(use_ehlo){
254 buffer[MAXBUF-1]='\0';
255 if(strstr(buffer, "250 STARTTLS") != NULL ||
256 strstr(buffer, "250-STARTTLS") != NULL){
257 supports_tls=TRUE;
258 }
259 }
261 if(use_ssl && ! supports_tls){
262 printf(_("WARNING - TLS not supported by server\n"));
263 send (sd, SMTP_QUIT, strlen (SMTP_QUIT), 0);
264 return STATE_WARNING;
265 }
267 #ifdef HAVE_SSL
268 if(use_ssl) {
269 /* send the STARTTLS command */
270 send(sd, SMTP_STARTTLS, strlen(SMTP_STARTTLS), 0);
272 recv(sd,buffer, MAX_INPUT_BUFFER-1, 0); /* wait for it */
273 if (!strstr (buffer, server_expect)) {
274 printf (_("Server does not support STARTTLS\n"));
275 send (sd, SMTP_QUIT, strlen (SMTP_QUIT), 0);
276 return STATE_UNKNOWN;
277 }
278 result = np_net_ssl_init(sd);
279 if(result != STATE_OK) {
280 printf (_("CRITICAL - Cannot create SSL context.\n"));
281 np_net_ssl_cleanup();
282 close(sd);
283 return STATE_CRITICAL;
284 } else {
285 ssl_established = 1;
286 }
288 /*
289 * Resend the EHLO command.
290 *
291 * RFC 3207 (4.2) says: ``The client MUST discard any knowledge
292 * obtained from the server, such as the list of SMTP service
293 * extensions, which was not obtained from the TLS negotiation
294 * itself. The client SHOULD send an EHLO command as the first
295 * command after a successful TLS negotiation.'' For this
296 * reason, some MTAs will not allow an AUTH LOGIN command before
297 * we resent EHLO via TLS.
298 */
299 if (my_send(helocmd, strlen(helocmd)) <= 0) {
300 printf(_("SMTP UNKNOWN - Cannot send EHLO command via TLS.\n"));
301 my_close();
302 return STATE_UNKNOWN;
303 }
304 if (verbose)
305 printf(_("sent %s"), helocmd);
306 if ((n = my_recv(buffer, MAX_INPUT_BUFFER - 1)) <= 0) {
307 printf(_("SMTP UNKNOWN - Cannot read EHLO response via TLS.\n"));
308 my_close();
309 return STATE_UNKNOWN;
310 }
311 if (verbose) {
312 buffer[n] = '\0';
313 printf("%s", buffer);
314 }
316 # ifdef USE_OPENSSL
317 if ( check_cert ) {
318 result = np_net_ssl_check_cert(days_till_exp);
319 if(result != STATE_OK){
320 printf (_("CRITICAL - Cannot retrieve server certificate.\n"));
321 }
322 my_close();
323 return result;
324 }
325 # endif /* USE_OPENSSL */
326 }
327 #endif
329 /* sendmail will syslog a "NOQUEUE" error if session does not attempt
330 * to do something useful. This can be prevented by giving a command
331 * even if syntax is illegal (MAIL requires a FROM:<...> argument)
332 *
333 * According to rfc821 you can include a null reversepath in the from command
334 * - but a log message is generated on the smtp server.
335 *
336 * You can disable sending mail_command with '--nocommand'
337 * Use the -f option to provide a FROM address
338 */
339 if (smtp_use_dummycmd) {
340 my_send(cmd_str, strlen(cmd_str));
341 my_recv(buffer, MAX_INPUT_BUFFER-1);
342 if (verbose)
343 printf("%s", buffer);
344 }
346 while (n < ncommands) {
347 asprintf (&cmd_str, "%s%s", commands[n], "\r\n");
348 my_send(cmd_str, strlen(cmd_str));
349 my_recv(buffer, MAX_INPUT_BUFFER-1);
350 if (verbose)
351 printf("%s", buffer);
352 strip (buffer);
353 if (n < nresponses) {
354 cflags |= REG_EXTENDED | REG_NOSUB | REG_NEWLINE;
355 errcode = regcomp (&preg, responses[n], cflags);
356 if (errcode != 0) {
357 regerror (errcode, &preg, errbuf, MAX_INPUT_BUFFER);
358 printf (_("Could Not Compile Regular Expression"));
359 return ERROR;
360 }
361 excode = regexec (&preg, buffer, 10, pmatch, eflags);
362 if (excode == 0) {
363 result = STATE_OK;
364 }
365 else if (excode == REG_NOMATCH) {
366 result = STATE_WARNING;
367 printf (_("SMTP %s - Invalid response '%s' to command '%s'\n"), state_text (result), buffer, commands[n]);
368 }
369 else {
370 regerror (excode, &preg, errbuf, MAX_INPUT_BUFFER);
371 printf (_("Execute Error: %s\n"), errbuf);
372 result = STATE_UNKNOWN;
373 }
374 }
375 n++;
376 }
378 if (authtype != NULL) {
379 if (strcmp (authtype, "LOGIN") == 0) {
380 char *abuf;
381 int ret;
382 do {
383 if (authuser == NULL) {
384 result = STATE_CRITICAL;
385 error_msg = _("no authuser specified, ");
386 break;
387 }
388 if (authpass == NULL) {
389 result = STATE_CRITICAL;
390 error_msg = _("no authpass specified, ");
391 break;
392 }
394 /* send AUTH LOGIN */
395 my_send(SMTP_AUTH_LOGIN, strlen(SMTP_AUTH_LOGIN));
396 if (verbose)
397 printf (_("sent %s\n"), "AUTH LOGIN");
399 if((ret = my_recv(buffer, MAXBUF - 1)) < 0){
400 error_msg = _("recv() failed after AUTH LOGIN, \n");
401 result = STATE_WARNING;
402 break;
403 }
404 buffer[ret] = 0;
405 if (verbose)
406 printf (_("received %s\n"), buffer);
408 if (strncmp (buffer, "334", 3) != 0) {
409 result = STATE_CRITICAL;
410 error_msg = _("invalid response received after AUTH LOGIN, ");
411 break;
412 }
414 /* encode authuser with base64 */
415 abuf = base64 (authuser, strlen(authuser));
416 strcat (abuf, "\r\n");
417 my_send(abuf, strlen(abuf));
418 if (verbose)
419 printf (_("sent %s\n"), abuf);
421 if ((ret = my_recv(buffer, MAX_INPUT_BUFFER-1)) == -1) {
422 result = STATE_CRITICAL;
423 error_msg = _("recv() failed after sending authuser, ");
424 break;
425 }
426 buffer[ret] = 0;
427 if (verbose) {
428 printf (_("received %s\n"), buffer);
429 }
430 if (strncmp (buffer, "334", 3) != 0) {
431 result = STATE_CRITICAL;
432 error_msg = _("invalid response received after authuser, ");
433 break;
434 }
435 /* encode authpass with base64 */
436 abuf = base64 (authpass, strlen(authpass));
437 strcat (abuf, "\r\n");
438 my_send(abuf, strlen(abuf));
439 if (verbose) {
440 printf (_("sent %s\n"), abuf);
441 }
442 if ((ret = my_recv(buffer, MAX_INPUT_BUFFER-1)) == -1) {
443 result = STATE_CRITICAL;
444 error_msg = _("recv() failed after sending authpass, ");
445 break;
446 }
447 buffer[ret] = 0;
448 if (verbose) {
449 printf (_("received %s\n"), buffer);
450 }
451 if (strncmp (buffer, "235", 3) != 0) {
452 result = STATE_CRITICAL;
453 error_msg = _("invalid response received after authpass, ");
454 break;
455 }
456 break;
457 } while (0);
458 } else {
459 result = STATE_CRITICAL;
460 error_msg = _("only authtype LOGIN is supported, ");
461 }
462 }
464 /* tell the server we're done */
465 my_send (SMTP_QUIT, strlen (SMTP_QUIT));
467 /* finally close the connection */
468 close (sd);
469 }
471 /* reset the alarm */
472 alarm (0);
474 microsec = deltime (tv);
475 elapsed_time = (double)microsec / 1.0e6;
477 if (result == STATE_OK) {
478 if (check_critical_time && elapsed_time > (double) critical_time)
479 result = STATE_CRITICAL;
480 else if (check_warning_time && elapsed_time > (double) warning_time)
481 result = STATE_WARNING;
482 }
484 printf (_("SMTP %s - %s%.3f sec. response time%s%s|%s\n"),
485 state_text (result),
486 (error_msg == NULL ? "" : error_msg),
487 elapsed_time,
488 verbose?", ":"", verbose?buffer:"",
489 fperfdata ("time", elapsed_time, "s",
490 (int)check_warning_time, warning_time,
491 (int)check_critical_time, critical_time,
492 TRUE, 0, FALSE, 0));
494 return result;
495 }
499 /* process command-line arguments */
500 int
501 process_arguments (int argc, char **argv)
502 {
503 int c;
505 int option = 0;
506 static struct option longopts[] = {
507 {"hostname", required_argument, 0, 'H'},
508 {"expect", required_argument, 0, 'e'},
509 {"critical", required_argument, 0, 'c'},
510 {"warning", required_argument, 0, 'w'},
511 {"timeout", required_argument, 0, 't'},
512 {"port", required_argument, 0, 'p'},
513 {"from", required_argument, 0, 'f'},
514 {"fqdn", required_argument, 0, 'F'},
515 {"authtype", required_argument, 0, 'A'},
516 {"authuser", required_argument, 0, 'U'},
517 {"authpass", required_argument, 0, 'P'},
518 {"command", required_argument, 0, 'C'},
519 {"response", required_argument, 0, 'R'},
520 {"nocommand", required_argument, 0, 'n'},
521 {"verbose", no_argument, 0, 'v'},
522 {"version", no_argument, 0, 'V'},
523 {"use-ipv4", no_argument, 0, '4'},
524 {"use-ipv6", no_argument, 0, '6'},
525 {"help", no_argument, 0, 'h'},
526 {"starttls",no_argument,0,'S'},
527 {"certificate",required_argument,0,'D'},
528 {0, 0, 0, 0}
529 };
531 if (argc < 2)
532 return ERROR;
534 for (c = 1; c < argc; c++) {
535 if (strcmp ("-to", argv[c]) == 0)
536 strcpy (argv[c], "-t");
537 else if (strcmp ("-wt", argv[c]) == 0)
538 strcpy (argv[c], "-w");
539 else if (strcmp ("-ct", argv[c]) == 0)
540 strcpy (argv[c], "-c");
541 }
543 while (1) {
544 c = getopt_long (argc, argv, "+hVv46t:p:f:e:c:w:H:C:R:SD:F:A:U:P:",
545 longopts, &option);
547 if (c == -1 || c == EOF)
548 break;
550 switch (c) {
551 case 'H': /* hostname */
552 if (is_host (optarg)) {
553 server_address = optarg;
554 }
555 else {
556 usage2 (_("Invalid hostname/address"), optarg);
557 }
558 break;
559 case 'p': /* port */
560 if (is_intpos (optarg))
561 server_port = atoi (optarg);
562 else
563 usage4 (_("Port must be a positive integer"));
564 break;
565 case 'F':
566 /* localhostname */
567 localhostname = strdup(optarg);
568 break;
569 case 'f': /* from argument */
570 from_arg = optarg;
571 smtp_use_dummycmd = 1;
572 break;
573 case 'A':
574 authtype = optarg;
575 break;
576 case 'U':
577 authuser = optarg;
578 break;
579 case 'P':
580 authpass = optarg;
581 break;
582 case 'e': /* server expect string on 220 */
583 server_expect = optarg;
584 break;
585 case 'C': /* commands */
586 if (ncommands >= command_size) {
587 commands = realloc (commands, command_size+8);
588 if (commands == NULL)
589 die (STATE_UNKNOWN,
590 _("Could not realloc() units [%d]\n"), ncommands);
591 }
592 commands[ncommands] = optarg;
593 ncommands++;
594 break;
595 case 'R': /* server responses */
596 if (nresponses >= response_size) {
597 responses = realloc (responses, response_size+8);
598 if (responses == NULL)
599 die (STATE_UNKNOWN,
600 _("Could not realloc() units [%d]\n"), nresponses);
601 }
602 responses[nresponses] = optarg;
603 nresponses++;
604 break;
605 case 'c': /* critical time threshold */
606 if (is_intnonneg (optarg)) {
607 critical_time = atoi (optarg);
608 check_critical_time = TRUE;
609 }
610 else {
611 usage4 (_("Critical time must be a positive integer"));
612 }
613 break;
614 case 'w': /* warning time threshold */
615 if (is_intnonneg (optarg)) {
616 warning_time = atoi (optarg);
617 check_warning_time = TRUE;
618 }
619 else {
620 usage4 (_("Warning time must be a positive integer"));
621 }
622 break;
623 case 'v': /* verbose */
624 verbose++;
625 break;
626 case 't': /* timeout */
627 if (is_intnonneg (optarg)) {
628 socket_timeout = atoi (optarg);
629 }
630 else {
631 usage4 (_("Timeout interval must be a positive integer"));
632 }
633 break;
634 case 'S':
635 /* starttls */
636 use_ssl = TRUE;
637 use_ehlo = TRUE;
638 break;
639 case 'D':
640 /* Check SSL cert validity */
641 #ifdef USE_OPENSSL
642 if (!is_intnonneg (optarg))
643 usage2 ("Invalid certificate expiration period",optarg);
644 days_till_exp = atoi (optarg);
645 check_cert = TRUE;
646 #else
647 usage (_("SSL support not available - install OpenSSL and recompile"));
648 #endif
649 break;
650 case '4':
651 address_family = AF_INET;
652 break;
653 case '6':
654 #ifdef USE_IPV6
655 address_family = AF_INET6;
656 #else
657 usage4 (_("IPv6 support not available"));
658 #endif
659 break;
660 case 'V': /* version */
661 print_revision (progname, revision);
662 exit (STATE_OK);
663 case 'h': /* help */
664 print_help ();
665 exit (STATE_OK);
666 case '?': /* help */
667 usage5 ();
668 }
669 }
671 c = optind;
672 if (server_address == NULL) {
673 if (argv[c]) {
674 if (is_host (argv[c]))
675 server_address = argv[c];
676 else
677 usage2 (_("Invalid hostname/address"), argv[c]);
678 }
679 else {
680 asprintf (&server_address, "127.0.0.1");
681 }
682 }
684 if (server_expect == NULL)
685 server_expect = strdup (SMTP_EXPECT);
687 if (mail_command == NULL)
688 mail_command = strdup("MAIL ");
690 if (from_arg==NULL)
691 from_arg = strdup(" ");
693 return validate_arguments ();
694 }
698 int
699 validate_arguments (void)
700 {
701 return OK;
702 }
705 int
706 my_close (void)
707 {
708 #ifdef HAVE_SSL
709 np_net_ssl_cleanup();
710 #endif
711 return close(sd);
712 }
715 void
716 print_help (void)
717 {
718 char *myport;
719 asprintf (&myport, "%d", SMTP_PORT);
721 print_revision (progname, revision);
723 printf ("Copyright (c) 1999-2001 Ethan Galstad <nagios@nagios.org>\n");
724 printf (COPYRIGHT, copyright, email);
726 printf("%s\n", _("This plugin will attempt to open an SMTP connection with the host."));
728 printf ("\n\n");
730 print_usage ();
732 printf (_(UT_HELP_VRSN));
734 printf (_(UT_HOST_PORT), 'p', myport);
736 printf (_(UT_IPv46));
738 printf (" %s\n", "-e, --expect=STRING");
739 printf (_(" String to expect in first line of server response (default: '%s')\n"), SMTP_EXPECT);
740 printf (" %s\n", "-n, nocommand");
741 printf (" %s\n", _("Suppress SMTP command"));
742 printf (" %s\n", "-C, --command=STRING");
743 printf (" %s\n", _("SMTP command (may be used repeatedly)"));
744 printf (" %s\n", "-R, --command=STRING");
745 printf (" %s\n", _("Expected response to command (may be used repeatedly)"));
746 printf (" %s\n", "-f, --from=STRING");
747 printf (" %s\n", _("FROM-address to include in MAIL command, required by Exchange 2000")),
748 #ifdef HAVE_SSL
749 printf (" %s\n", "-D, --certificate=INTEGER");
750 printf (" %s\n", _("Minimum number of days a certificate has to be valid."));
751 printf (" %s\n", "-S, --starttls");
752 printf (" %s\n", _("Use STARTTLS for the connection."));
753 #endif
755 printf (" %s\n", "-A, --authtype=STRING");
756 printf (" %s\n", _("SMTP AUTH type to check (default none, only LOGIN supported)"));
757 printf (" %s\n", "-U, --authuser=STRING");
758 printf (" %s\n", _("SMTP AUTH username"));
759 printf (" %s\n", "-P, --authpass=STRING");
760 printf (" %s\n", _("SMTP AUTH password"));
762 printf (_(UT_WARN_CRIT));
764 printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT);
766 printf (_(UT_VERBOSE));
768 printf("\n");
769 printf ("%s\n", _("Successul connects return STATE_OK, refusals and timeouts return"));
770 printf ("%s\n", _("STATE_CRITICAL, other errors return STATE_UNKNOWN. Successful"));
771 printf ("%s\n", _("connects, but incorrect reponse messages from the host result in"));
772 printf ("%s\n", _("STATE_WARNING return values."));
774 printf (_(UT_SUPPORT));
775 }
779 void
780 print_usage (void)
781 {
782 printf (_("Usage:"));
783 printf ("%s -H host [-p port] [-e expect] [-C command] [-f from addr]", progname);
784 printf ("[-A authtype -U authuser -P authpass] [-w warn] [-c crit] [-t timeout]\n");
785 printf ("[-S] [-D days] [-n] [-v] [-4|-6]\n");
786 }