python FTP SMTP POP3 IMAP DNS
Posted on February 1, 2015
Tags: hacksoft
from ftplib import FTP
= 'ftp.cs.brown.edu'
FTP_HOST = 'anonymous'
FTP_USER = ''
FTP_PASS
= "README"
DOWNLOAD_FILE
##with FTP_TLS(host=FTP_HOST,user=FTP_USER,passwd=FTP_PASS,timeout=15) as conn:
## connection.dir()
with FTP(host=FTP_HOST,user=FTP_USER,passwd=FTP_PASS,timeout=15) as conn:
dir() #ls
conn.# drwxrwxrwt 2 0 0 523817 Oct 22 08:30 incoming
# drwxr-xr-x 33 0 2 2323 Aug 13 2013 pub
# drwxr-xr-x 52 0 2 1087 Feb 11 2016 u
print(" --- "* 10)
"pub") #cd pub
conn.cwd(dir() #ls
conn.with open(DOWNLOAD_FILE,mode="wb") as file:
f"RETR {DOWNLOAD_FILE}", lambda data: file.write(data))
conn.retrbinary(
POP3 vs IMAP4 vs SMTP
- SMPTP
- ports: 25 unsecure, 465 popular, 587 secure, 2525 unofficial
- IMAP
- emails stored on server
- ports: 143 unsecure, 993 secure
- POP3
- no emails left onserver (best for privacy)
- ports: 110 unsecure , 995 secure