This collective work is Copyright (C) 2002, 2003 Eric S. Raymond Copyright (C) 2004 Matthias Andree, Eric S. Raymond, Robert M. Funk, Graham Wilson Copyright (C) 2005 - 2012 Sunil Shetye Copyright (C) 2005 - 2021 Matthias Andree Some older portions not explicitly mentioned above are copyrighted by Carl E. Harris, George M. Sipe, Graham Wilson, Matthias Andree and Sunil Shetye. SSL library considerations ~~~~~~~~~~~~~~~~~~~~~~~~~~ If linking against OpenSSL versions under dual OpenSSL/SSLeay license (f. i. OpenSSL 1.1.1x and older) is enabled at configure/compile time, the following clause applies: | This product includes software developed by the OpenSSL Project | for use in the OpenSSL Toolkit. (http://www.openssl.org/) |Linking fetchmail statically or dynamically with other modules is making |a combined work based on fetchmail. Thus, the terms and conditions |of the GNU General Public License cover the whole combination. | |In addition, as a special exception, the copyright holders of fetchmail |give you permission to combine fetchmail with free |software programs or libraries that are released under the GNU LGPL and with |code included in the standard release of OpenSSL under the OpenSSL or SSLeay license |(or modified versions of such code, with unchanged license). | |You may copy and distribute such a system following the terms of the GNU GPL |for fetchmail and the licenses of the other code concerned, |provided that you include the source code of that other code when and as the |GNU GPL requires distribution of source code. | |Note that people who make modified versions of fetchmail are not obligated to |grant this special exception for their modified versions; it is their choice |whether to do so. The GNU General Public License gives permission to release |a modified version without this exception; this exception also makes it |possible to release a modified version which carries forward this exception. | |In short: Specific permission is granted for the GPLed code in this distribution to be linked to OpenSSL without invoking GPL clause 2(b). Note that this permission applies to OpenSSL, and OpenSSL only. The Free Software Foundation asserts that a GPL v2 clause 2b exception is required even for dynamically linked binaries. See https://www.gnu.org/licenses/gpl-faq.en.html#GPLStaticVsDynamic If linking against OpenSSL versions licensed under the Apache License version 2.0 (for instance, OpenSSL 3.0.x), note that this library is incompatible with the GPLv2, so that effectively, distributors need to use the "or any later version" grant in the GPLv2 and apply the GPLv3 which is considered compatible with the Apache License 2.0 by the FSF and the ASF. Fetchmail can be linked against wolfSSL, which is under GNU General Public License v2, or optionally, any later version. ~~~~~~~~~~~~~~~~~~~~~~~~~~ The support for SMB authentication is copyright by Andrew Tridgell and is under GPL version 2 (or any later version). Andrew Tridgell has granted a specific exemption for his GPL-licensed code to be linked with non-GPL-compliant code in fetchmail. The relevant files are smb*.[ch] and ntlm.h. The following files are public-domain: acconfig.h, md5c.c, md5.h. The following files are explicitly GPL-licensed (v2 or any later version): getopt1.c, getopt.c, getopt.h. The file m4-local/ac_ma_search_package.m4 is copyright by Caolan McNamara with fixes from Alexandre Duret-Lutz , Matthew Mueller and Matthias Andree The license is detailed in m4-local/ac-archive-license.txt and is a relaxed GPLv2-or-later version. The *.c files in the ucs/ directory are Copyright (C) 2002, 2003 by Markus Kuhn, with a liberal license as follows: | Permission to use, copy, modify, and distribute this software | for any purpose and without fee is hereby granted. The author | disclaims all warranties with regard to this software. The trio/ code is Copyright (C) 1998-2001 by Bjorn Reese and Daniel Stenberg and also under a liberal license: | Permission to use, copy, modify, and distribute this software for any | purpose with or without fee is hereby granted, provided that the above | copyright notice and this permission notice appear in all copies. | | THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED | WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF | MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND | CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER. The libesmtp/* files functions are (C) by Brian Stafford, see the respective file headers for details (LGPL v2.1 or later). The KAME/* files are (C) Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project, see the respective file headers for details. All other code in the distribution incorporates the copy of GPL version 2 below by reference. -----
#!/usr/bin/expect -f

# MySQL database connection settings
set CRDB_host     localhost
set CRDB_DB       test
set CRDB_username root
set CRDB_password root

# set eiter one to 1 for verbose output
log_user 0
set comments 0

package require mysqltcl

# connect to MySQL database
set handle [::mysql::connect -host $CRDB_host -user $CRDB_username -password $CRDB_password]

# get server/usernames to clean up
set userlist [::mysql::sel $handle "SELECT UserID, server, username, password, retaindays from $CRDB_DB.fetchmail_user" -flatlist]

# loop through all users in database
foreach {userid server username password days} $userlist {
  if {$comments==1} { send_user "\r\nWorking on accound #$userid\r\n*******************************\r\n" }
  eval spawn telnet -l fetchmail_cleanup $server 110
  expect "ready"
  send "USER $username\r"
  expect "password"
  send "PASS $password\r"
  expect "OK"
  send "STAT\r"
  expect "+OK "
  expect -re "\[0-9]* "
  set anz $expect_out(0,string)
  if {$comments==1} { send_user "message count: $anz \r\n" }
  set i 0
  while { $i < $anz } {
    incr i
    send "UIDL $i\r"
    expect -re "\\\+OK $i \(.*\)\r"
    set uid $expect_out(1,string)
    ::mysql::exec $handle "insert ignore into $CRDB_DB.fetchmail values ($userid,'$uid',now());"
    set age [::mysql::sel $handle "SELECT DATEDIFF(now(),Fetchdate) from $CRDB_DB.fetchmail where UserID=$userid and UID='$uid'" -list]
    if {$comments==1}