Code

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