همه توضیحات را Command کردم :
# Az imaplib Baraye Connect Shodan B Server Gmail Estefade Mikonim
import imaplib
# dar inja Ba Estefade Az Method IMAP4_SSL Baraye Moshakhas Kardan Server Morede Nazar Va Sakhtan Proxy Estefade Mikonim
#Ba Port 993 Vasl Mishim ahmiat Chandani Ham Dar In Bakhsh Ndare albate Az Rahaye Dge MOnzorame
mailserver = imaplib.IMAP4_SSL('imap.gmail.com', 993)
# Dar In Ghesmat Name Email Morede Bazar
username = 'USERNAME'
# Dar In Ghesmat Password Email Morede Bazar
password= 'PASSWORD'
#Dar Inja Ham LOGIN Kardan B server GMAIL K Baraye In Mesal Dar Nazar Gerftim Ba Method LOGIN
mailserver.login(username, password)
# Dar Inja Ham 2 Motghayer Tarif Kardim k Az Inbox Mail Ho33eini Az Server Gmail Ro Bekhonim
# Motghayer STATUS Dar In Barname Estefade Nemikonim Va Agar Dost Dashtid Mitonid Baraye ExceptHa Az Ann Estefade KOnid
# Ya Inke Bekhahid az IF Estefade Konid
# Shart Mslan
# STATUS != 'OK'
status, count =mailserver.select('inbox')
# Dar Inja Ham Fetch Kardan Etelaat Gerfte Shode Az INBOX Mail Ho33eini K Ba Ebarat Zir Tarikh NameGirrande NameFerstande Va Subject Ro Dar Command Line Neshan Midahah
# SUBJECT TO FROM Date
#ebarat HEADER.FIELDS Ham Baraye DastYabi B Keys K Dar Akhar Code Command Kardamn Hame Roo.
status, data = mailserver.fetch(count[0],'(BODY[HEADER.FIELDS (SUBJECT TO FROM Date)])')
#Print Ebarat Mojod Dar DATA B Dalil inke Yek Arraye 2 Boodi ast Ba Index MOred Nazar Por MIkonim
print (data[0][1])
#ina Ham Dge Niaz B Tozih Nis Kamelan Moshakhas
mailserver.close()
mailserver.logout()
#Keys // Baraye Gerftan Har Qesmat Az Az Email Ebarat Morede Nazar Ra Qarar Dahid
#'Received', 'Received', 'Received', 'Cc', 'Message-Id', 'From', 'To',
#In-Reply-To', 'Content-Type', 'Content-Transfer-Encoding', 'Mime-Version',
#Subject', 'Date', 'References', 'X-Mailer',
#X-yoursite-MailScanner-Information',
#X-yoursite-MailScanner', 'X-yoursite-MailScanner-From', 'Return-Path',
#X-OriginalArrivalTime']
#in Ham Ye Link Baraye Kar Ba MethodHaye IMAPLIB
#http://tools.ietf.org/html/rfc1730#section-6.4.5
عکسی از خروجی: