sub smtptls_login {
    use Net::SMTP::TLS;
    my($host, $port, $notls, $helo, $account, $password) = @_;

    eval('
    $smtp = new Net::SMTP::TLS(
	$host,
	Port => $port,
	NoTLS => $notls,
	Timeout => 60,
	Hello => $helo,
	User => $account,
	Password => $password
    );
');
    $result = $@;
    $result =~ s/\n.*$//;
    print($result);
    eval('$smtp->quit;') if ($smtp);
    if ($result) {
	if ((! $notls) and ($result =~ /TLS not available/)) {
	    eval('
    $smtp = new Net::SMTP::TLS(
	$host,
	Port => $port,
	NoTLS => 1,
	Timeout => 60,
	Hello => $helo,
	User => $account,
	Password => $password
    );
');
	    $result = $@;
	    $result =~ s/\n.*$//;
	    print($result);
	    eval('$smtp->quit;') if ($smtp);
	    return($result ? 0 : 1);
	} else {
	    return(0);
	}
    } else {
	return(1);
    }
}
