smtp.c
/*
** print info about SMTP server on stdout
** return 0 on success -1 on error
*/
print info about SMTP server on stdout
return 0 on success -1 on error
print info about SMTP server on stdout return 0 on success - 1 on error
int show_smtp_info(char *smtp_server,int port,char *domain)
{
    int
        fd,
        rc = (-1);
#ifdef HAVE_OPENSSL
    SSL
        *ssl=NULL;
#endif 
    g_verbose=1;
    print_info("Connecting to SMTP server: %s at Port: %d\n",smtp_server,port);
    print_info("Connection timeout: %d secs\n",g_connect_timeout);
    fd=smtpConnect(smtp_server,port);
    if (fd == INVALID_SOCKET)
    {
        rc = (-1);
        goto ExitProcessing;
    }
#ifdef HAVE_OPENSSL
    if (g_do_ssl)
    {
        ssl=msock_get_ssl();
        if (ssl)
        {
            if (!SSL_set_fd(ssl,fd))
            {
                errorMsg("failed to set socket to SSL\n");
                goto ExitProcessing;
            }
            msock_set_ssl(ssl);
            rc=SSL_connect(ssl);
            if (rc < 1)
            {
                errorMsg("SSL connection failed\n");
                ERR_print_errors_fp(stderr);
                goto ExitProcessing;
            }
            print_cert_info(ssl);
            msock_turn_ssl_on();
            rc=0;
        }
    }
#endif 
    rc=read_greetings();
    if (rc < 0)
    {
        errorMsg("Could not read greetings\n");
        goto ExitProcessing;
    }
    say_helo(domain);
    if (check_server_cap("STARTTLS") ||
        check_server_cap("TLS"))
    {
        rc=smtp_start_tls(fd);
        if (rc == 0)
            say_helo(domain);
        else
            goto ExitProcessing;
    }
    smtp_QUIT();
    smtpDisconnect();
ExitProcessing:
    return (rc);
}
int show_smtp_info ( char * smtp_server , int port , char * domain ) { int fd , rc = ( -1 ) ; #ifdef HAVE_OPENSSL SSL * ssl = NULL ; #endif g_verbose = 1 ; print_info ( " \n " , smtp_server , port ) ; print_info ( " \n " , g_connect_timeout ) ; fd = smtpConnect ( smtp_server , port ) ; if ( fd == INVALID_SOCKET ) { rc = ( -1 ) ; goto ExitProcessing ; } #ifdef HAVE_OPENSSL if ( g_do_ssl ) { ssl = msock_get_ssl ( ) ; if ( ssl ) { if ( ! SSL_set_fd ( ssl , fd ) ) { errorMsg ( " \n " ) ; goto ExitProcessing ; } msock_set_ssl ( ssl ) ; rc = SSL_connect ( ssl ) ; if ( rc < 1 ) { errorMsg ( " \n " ) ; ERR_print_errors_fp ( stderr ) ; goto ExitProcessing ; } print_cert_info ( ssl ) ; msock_turn_ssl_on ( ) ; rc = 0 ; } } #endif rc = read_greetings ( ) ; if ( rc < 0 ) { errorMsg ( " \n " ) ; goto ExitProcessing ; } say_helo ( domain ) ; if ( check_server_cap ( " " ) || check_server_cap ( " " ) ) { rc = smtp_start_tls ( fd ) ; if ( rc == 0 ) say_helo ( domain ) ; else goto ExitProcessing ; } smtp_QUIT ( ) ; smtpDisconnect ( ) ; ExitProcessing : return ( rc ) ; }
print info about SMTP server on stdout
return 0 on success -1 on error
print info about SMTP server on stdout return 0 on success - 1 on error
/* HAVE_OPENSSL */ /* connect */ /* must set back to msock's static */ /* tell msock everything is ssl after that */ /* HAVE_OPENSSL */ /* read greeting */ /* say HELO/EHLO */ /* check if server supports STARTTLS */