Server added to command line arguments
[imap-restore-mail] / src / mail_iterator.py
index 12ed42d..e46c312 100644 (file)
@@ -24,8 +24,6 @@ MAILBOX_RESP = re.compile(r'\((?P<flags>.*?)\) "(?P<delimiter>.*)" (?P<name>.*)'
 UIDVAL_RESP = re.compile(r'(?P<name>.*) \(UIDVALIDITY (?P<uidval>.*)\)')
 ACLS_RESP = re.compile(b'(?P<user>.*) (?P<acls>.*)')
 
-SERVER = "localhost"
-
 class MailIterator:
     """This class communicates with the e-mail server."""
 
@@ -37,12 +35,12 @@ class MailIterator:
     # logged in status
     logged_in = None
 
-    def __init__(self, username, password):
+    def __init__(self, server, username, password):
         """Creates a connection and a user session."""
 
         # connect to server
         try:
-            self.mail_con = imaplib.IMAP4(SERVER)
+            self.mail_con = imaplib.IMAP4(server)
 
             # socket functionality (currently unavailable)
             #imap_socket = socket.socket(socket.AF_UNIX)
@@ -50,7 +48,7 @@ class MailIterator:
             #self.mail_con.sock = imap_socket
             #self.mail_con.file = self.mail_con.sock.makefile('rb')
 
-            logging.info("Connected to %s", SERVER)
+            logging.info("Connected to %s", server)
         except (socket.error, self.mail_con.error) as ex:
             logging.error("Could not connect to host: %s", ex)
             sys.exit()