Feb-03-2021, 04:07 PM
This python code writing configuration file for getmail to retrieve the mail, in the first and last f.write code i use the "\n" to break the lines for new line:
cur = conn.cursor() query = "SELECT user, passwd, server FROM pop" cur.execute(query) for idx, row in enumerate(cur, start=1): with open(f'mail{idx}', 'w') as f: f.write('[options]\n verbose = 1\n read_all = false\n delete = true\n received = false\n delivered_to = false\n message_log = /home/mail/log\n message_log_verbose = true\n ') f.write('username = ') f.write(row[0]) f.write("\n") f.write(' password = ') f.write(row[1]) f.write("\n") f.write(' server = ') f.write(row[2]) f.write("\n") f.write('[destination]\n type = MDA_external\n path = /usr/bin/exim\n arguments = ("-i", "-bm", "user@localhost")\n unixfrom = true\n ')with cat the file seem ok there is no '\n' in the end of lines, but when run the getmail get the error:
Configuration error: configuration file /home/mail/mail1 incorrect (File contains parsing errors: /home/mail/mail1 [line 2]: ' verbose = 1\n' [line 3]: ' read_all = false\n' [line 4]: ' delete = true\n' [line 5]: ' received = false\n' [line 6]: ' delivered_to = false\n'how to remove the '\n' from the end of lines.