0
import imaplib, email
        with open('Accounts.txt', 'r') as f:
            data = f.readline()[1:]    
        user, password = data.split(':')
        with open(b'serverimap.txt', 'r') as good:
            serverss = good.readlines()  
        mail = imaplib.IMAP4_SSL(serverss, 993)
        mail.login(user, password)
        print("logged")
        mail.select("INBOX", "Junk")

i get error "getaddrinfo() argument 1 must be string or None " error after call this code my account and imap server in txt files

petezurich
  • 9,280
  • 9
  • 43
  • 57

1 Answers1

0

readlines() returns a list - and apparently IMAP4_SSL() is looking for a string. Consider changing readlines() to just read().

serverss = good.read()  
Mark
  • 4,249
  • 1
  • 18
  • 27
  • i got now LOGIN command error: BAD [b'expected closing DQUOTE'] after call the code with good.read() – ربح مضمون Jun 27 '22 at 18:09
  • You'll need to share the `Accounts.txt` file. It looks like you are reading the first line only, and skipping the first character. It appears as if the mail.login() call is now failing. – Mark Jun 28 '22 at 15:34
  • when i use print the email not skipping first character so what's problem – ربح مضمون Jun 28 '22 at 21:45