{"id":297,"date":"2021-09-06T13:57:46","date_gmt":"2021-09-06T10:57:46","guid":{"rendered":"https:\/\/is42-2018.susu.ru\/artyushkinana\/?p=297"},"modified":"2021-09-06T13:57:46","modified_gmt":"2021-09-06T10:57:46","slug":"rabota-s-email","status":"publish","type":"post","link":"https:\/\/is42-2018.susu.ru\/artyushkinana\/2021\/09\/06\/rabota-s-email\/","title":{"rendered":"\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 EMail"},"content":{"rendered":"<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0447\u0438\u0442\u0430\u0442\u044c \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u044b\u0435 \u043f\u0438\u0441\u044c\u043c\u0430, \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u043e\u0442 \u044d\u0442\u043e\u0442 \u043a\u043e\u0434:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">\r\nimport imaplib\r\nimport email\r\nfrom email.header import decode_header\r\nimport webbrowser\r\nimport os\r\n# \u0443\u0447\u0435\u0442\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435\r\nusername = \"uru07082000@gmail.com\"\r\npassword = \"password\"\r\ndef clean(text):\r\n# \u0447\u0438\u0441\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0430\u043f\u043a\u0438\r\nreturn \"\".join(c if c.isalnum() else \"_\" for c in text)\r\n# create an IMAP4 class with SSL\r\nimap = imaplib.IMAP4_SSL(\"imap.gmail.com\")\r\n# authenticate\r\nimap.login(username, password)\r\nstatus, messages = imap.select(\"INBOX\")\r\n# \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u043f\u0438\u0441\u0435\u043c \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f\r\nN = 1\r\n# \u043e\u0431\u0449\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0438\u0441\u0435\u043c\r\nmessages = int(messages[0])\r\nfor i in range(messages, messages-N, -1):\r\n# fetch the email message by ID\r\nres, msg = imap.fetch(str(i), \"(RFC822)\")\r\nfor response in msg:\r\nif isinstance(response, tuple):\r\n# parse a bytes email into a message object\r\nmsg = email.message_from_bytes(response[1])\r\n# decode the email subject\r\nsubject, encoding = decode_header(msg[\"Subject\"])[0]\r\nif isinstance(subject, bytes):\r\n# if it's a bytes, decode to str\r\nsubject = subject.decode(encoding)\r\n# decode email sender\r\nFrom, encoding = decode_header(msg.get(\"From\"))[0]\r\nif isinstance(From, bytes):\r\nFrom = From.decode(encoding)\r\nprint(\"Subject:\", subject)\r\nprint(\"From:\", From)\r\n# if the email message is multipart\r\nif msg.is_multipart():\r\n# iterate over email parts\r\nfor part in msg.walk():\r\n# extract content type of email\r\ncontent_type = part.get_content_type()\r\ncontent_disposition = str(part.get(\"Content-Disposition\"))\r\ntry:\r\n# get the email body\r\nbody = part.get_payload(decode=True).decode()\r\nexcept:\r\npass\r\nif content_type == \"text\/plain\" and \"attachment\" not in content_disposition:\r\n# print text\/plain emails and skip attachments\r\nprint(body)\r\nelif \"attachment\" in content_disposition:\r\n# download attachment\r\nfilename = part.get_filename()\r\nif filename:\r\nfolder_name = clean(subject)\r\nif not os.path.isdir(folder_name):\r\n# make a folder for this email (named after the subject)\r\nos.mkdir(folder_name)\r\nfilepath = os.path.join(folder_name, filename)\r\n# download attachment and save it\r\nopen(filepath, \"wb\").write(part.get_payload(decode=True))\r\nelse:\r\n# extract content type of email\r\ncontent_type = msg.get_content_type()\r\n# get the email body\r\nbody = msg.get_payload(decode=True).decode()\r\nif content_type == \"text\/plain\":\r\n# print only text email parts\r\nprint(body)\r\nif content_type == \"text\/html\":\r\n# if it's HTML, create a new HTML file and open it in browser\r\nfolder_name = clean(subject)\r\nif not os.path.isdir(folder_name):\r\n# make a folder for this email (named after the subject)\r\nos.mkdir(folder_name)\r\nfilename = \"index.html\"\r\nfilepath = os.path.join(folder_name, filename)\r\n# write the file\r\nopen(filepath, \"w\").write(body)\r\n# open in the default browser\r\nwebbrowser.open(filepath)\r\nprint(\"=\"*100)\r\n# close the connection and logout\r\nimap.close()\r\nimap.logout()\r\n<\/pre>\n<p>\u041a\u0430\u043a \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u044b\u0435 \u043f\u0438\u0441\u044c\u043c\u0430 \u0432 Python?<br \/>\n\u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u044b\u0435 \u043f\u0438\u0441\u044c\u043c\u0430, \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u043e\u0442 \u044d\u0442\u043e\u0442 \u043a\u043e\u0434:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">\r\nimport imaplib\r\nimport email\r\nfrom email.header import decode_header\r\n# \u0443\u0447\u0435\u0442\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435\r\nusername = \"uru07082000@gmail.com\"\r\npassword = \"password\"\r\n# create an IMAP4 class with SSL\r\nimap = imaplib.IMAP4_SSL(\"imap.gmail.com\")\r\n# authenticate\r\nimap.login(username, password)\r\n# select the mailbox I want to delete in\r\n# if you want SPAM, use imap.select(\"SPAM\") instead\r\nimap.select(\"INBOX\")\r\n# \u043f\u043e\u0438\u0441\u043a \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u043f\u0438\u0441\u0435\u043c \u043f\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u0435\u043b\u044e\r\nstatus, messages = imap.search(None, \"FROM\", \"schvirkov@mail.ru\")\r\n# \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0432 \u0441\u043f\u0438\u0441\u043e\u043a \u0430\u0434\u0440\u0435\u0441\u043e\u0432 \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u043e\u0439 \u043f\u043e\u0447\u0442\u044b\r\nmessages = messages[0].split(b' ')\r\ntry:\r\nfor mail in messages:\r\n_, msg = imap.fetch(mail, \"(RFC822)\")\r\n# \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0446\u0438\u043a\u043b for \u0434\u043b\u044f \u043f\u043e\u0432\u044b\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0434\u043b\u0438\u043d\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u0438\u0441\u0435\u043c\r\n# \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043e\u043d \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043f\u0435\u0447\u0430\u0442\u0438 SUBJECT \u0446\u0435\u043b\u0435\u0432\u043e\u0433\u043e \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u043e\u0433\u043e \u043f\u0438\u0441\u044c\u043c\u0430, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043d\u0443\u0436\u043d\u043e \u0443\u0434\u0430\u043b\u0438\u0442\u044c\r\nfor response in msg:\r\nif isinstance(response, tuple):\r\nmsg =\r\n \r\nemail.message_from_bytes(response[1])\r\n# \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0435\u043c\u0443 \u043f\u0438\u0441\u044c\u043c\u0430\r\nsubject = decode_header(msg[\"Subject\"])[0][0]\r\nif isinstance(subject, bytes):\r\n# if it's a bytes type, decode to str\r\nsubject = subject.decode()\r\nprint(\"Deleting\", subject)\r\n# \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c \u043f\u0438\u0441\u044c\u043c\u043e \u043a\u0430\u043a \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u043e\u0435\r\nimap.store(mail, \"+FLAGS\", \"\\\\Deleted\")\r\nexcept:\r\nprint(\"\u0412\u0441\u0435 \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u043e\")\r\n# \u043d\u0430\u0432\u0441\u0435\u0433\u0434\u0430 \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u043f\u0438\u0441\u044c\u043c\u0430, \u043f\u043e\u043c\u0435\u0447\u0435\u043d\u043d\u044b\u0435 \u043a\u0430\u043a \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u044b\u0435\r\n# \u0438\u0437 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0447\u0442\u043e\u0432\u043e\u0433\u043e \u044f\u0449\u0438\u043a\u0430 (\u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 INBOX)\r\nimap.expunge()\r\n# \u0437\u0430\u043a\u0440\u044b\u0442\u044c \u043f\u043e\u0447\u0442\u043e\u0432\u044b\u0439 \u044f\u0449\u0438\u043a\r\nimap.close()\r\n# \u0432\u044b\u0439\u0442\u0438 \u0438\u0437 \u0430\u043a\u043a\u0430\u0443\u043d\u0442\u0430\r\nimap.logout()\r\n<\/pre>\n<p>\u041a\u0430\u043a \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u044b\u0435 \u043f\u0438\u0441\u044c\u043c\u0430 \u0441 Python?<br \/>\n\u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u044b\u0435 \u043f\u0438\u0441\u044c\u043c\u0430, \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u043e\u0442 \u044d\u0442\u043e\u0442 \u043a\u043e\u0434:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">\r\nimport smtplib\r\nfrom email import encoders\r\nfrom email.mime.text import MIMEText\r\nfrom email.mime.multipart import MIMEMultipart\r\nfrom email.mime.base import MIMEBase\r\nfrom bs4 import BeautifulSoup as bs\r\n# \u0432\u0430\u0448\u0438 \u0443\u0447\u0435\u0442\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435\r\nemail = \"uru07082000\"\r\npassword = \"password\"\r\n# \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u0430\u044f \u043f\u043e\u0447\u0442\u0430 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u0435\u043b\u044f\r\nFROM = \"uru07082000@gmail.com\"\r\n# \u0430\u0434\u0440\u0435\u0441 \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u043e\u0439 \u043f\u043e\u0447\u0442\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u0435\u043b\u044f\r\nTO = \"incdd@yandex.ru\"\r\n# \u0442\u0435\u043c\u0430 \u043f\u0438\u0441\u044c\u043c\u0430 (\u0442\u0435\u043c\u0430)\r\nsubject = \"Test\"\r\n# \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0445\u043e\u0442\u0438\u043c \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c\r\nmsg = MIMEMultipart(\"alternative\")\r\n# \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0430\u0434\u0440\u0435\u0441 \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u043e\u0439 \u043f\u043e\u0447\u0442\u044b \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u0435\u043b\u044f\r\nmsg[\"From\"] = FROM\r\n# \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0430\u0434\u0440\u0435\u0441 \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u043e\u0439 \u043f\u043e\u0447\u0442\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u0435\u043b\u044f\r\nmsg[\"To\"] = TO\r\n# \u0437\u0430\u0434\u0430\u0435\u043c \u0442\u0435\u043c\u0443\r\nmsg[\"Subject\"] = subject\r\n# \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0442\u0435\u043b\u043e \u043f\u0438\u0441\u044c\u043c\u0430 \u043a\u0430\u043a HTML\r\nhtml = \"\"\"\r\nMail Python!\r\n\"\"\"\r\n# \u0434\u0435\u043b\u0430\u0435\u043c \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e HTML\r\ntext = bs(html, \"html.parser\").text\r\ntext_part = MIMEText(text, \"plain\")\r\nhtml_part = MIMEText(html, \"html\")\r\n# \u043f\u0440\u0438\u043a\u0440\u0435\u043f\u0438\u0442\u044c \u0442\u0435\u043b\u043e \u043f\u0438\u0441\u044c\u043c\u0430 \u043a \u043f\u043e\u0447\u0442\u043e\u0432\u043e\u043c\u0443 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044e\r\n# \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u0438\u043a\u0440\u0435\u043f\u0438\u0442\u0435 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e\r\nmsg.attach(text_part)\r\nmsg.attach(html_part)\r\nprint(msg.as_string())\r\ndef send_mail(email, password, FROM, TO, msg):\r\n# \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c SMTP-\u0441\u0435\u0440\u0432\u0435\u0440\r\nserver = smtplib.SMTP(\"smtp.gmail.com\", 587)\r\n# \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c\u0441\u044f \u043a SMTP-\u0441\u0435\u0440\u0432\u0435\u0440\u0443 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 TLS (\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0439) \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c EHLO\r\nserver.starttls()\r\n# \u0432\u043e\u0439\u0442\u0438 \u0432 \u0443\u0447\u0435\u0442\u043d\u0443\u044e \u0437\u0430\u043f\u0438\u0441\u044c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0443\u0447\u0435\u0442\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435\r\nserver.login(email, password)\r\n# \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u043e\u0435 \u043f\u0438\u0441\u044c\u043c\u043e\r\nserver.sendmail(FROM, TO, msg.as_string())\r\n# \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0442\u044c \u0441\u0435\u0430\u043d\u0441 SMTP\r\nserver.quit()\r\nsend_mail(email, password, FROM, TO, msg)\r\n\u0422\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0440\u0430\u0441\u0441\u044b\u043b\u043a\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u044d\u0442\u043e\u0433\u043e \u043a\u043e\u0434\u0430:\r\nimport smtplib\r\nfrom email.mime.text import MIMEText\r\nfrom email.mime.multipart import MIMEMultipart\r\nfrom bs4 import BeautifulSoup as bs\r\nto_list = ['incdd@yandex.ru', 'poselennov.il@ya.ru']\r\ndef send_mail(email, password, FROM, TO, msg):\r\n# \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c SMTP-\u0441\u0435\u0440\u0432\u0435\u0440\r\nserver = smtplib.SMTP(\"smtp.gmail.com\", 587)\r\n# \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c\u0441\u044f \u043a SMTP-\u0441\u0435\u0440\u0432\u0435\u0440\u0443 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 TLS (\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0439) \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c EHLO\r\nserver.starttls()\r\n# \u0432\u043e\u0439\u0442\u0438 \u0432 \u0443\u0447\u0435\u0442\u043d\u0443\u044e \u0437\u0430\u043f\u0438\u0441\u044c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0443\u0447\u0435\u0442\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435\r\nserver.login(email, password)\r\n# \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u043e\u0435 \u043f\u0438\u0441\u044c\u043c\u043e\r\nserver.sendmail(FROM, TO, msg.as_string())\r\n# \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0442\u044c \u0441\u0435\u0430\u043d\u0441 SMTP\r\nserver.quit()\r\nfor recipient in to_list:\r\n# \u0432\u0430\u0448\u0438 \u0443\u0447\u0435\u0442\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435\r\nemail = \"uru07082000@gmail.com\"\r\npassword = \"password\"\r\n# \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u0430\u044f \u043f\u043e\u0447\u0442\u0430 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u0435\u043b\u044f\r\nFROM = \"uru07082000@gmail.com\"\r\n# \u0430\u0434\u0440\u0435\u0441 \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u043e\u0439 \u043f\u043e\u0447\u0442\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u0435\u043b\u044f\r\nTO = recipient\r\n# \u0442\u0435\u043c\u0430 \u043f\u0438\u0441\u044c\u043c\u0430 (\u0442\u0435\u043c\u0430)\r\nsubject = \"\u041f\u0440\u0438\u043a\u043e\u043b\"\r\n# \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0445\u043e\u0442\u0438\u043c \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c\r\nmsg = MIMEMultipart(\"alternative\")\r\n# \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0430\u0434\u0440\u0435\u0441 \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u043e\u0439 \u043f\u043e\u0447\u0442\u044b \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u0435\u043b\u044f\r\nmsg[\"From\"] = FROM\r\n# \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0430\u0434\u0440\u0435\u0441 \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u043e\u0439 \u043f\u043e\u0447\u0442\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u0435\u043b\u044f\r\nmsg[\"To\"] = TO\r\n# \u0437\u0430\u0434\u0430\u0435\u043c \u0442\u0435\u043c\u0443\r\nmsg[\"Subject\"] = subject\r\n# \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0442\u0435\u043b\u043e \u043f\u0438\u0441\u044c\u043c\u0430 \u043a\u0430\u043a HTML\r\nhtml = \"\"\"\r\n\u0420\u0430\u0441\u0441\u044b\u043b\u043a\u0430 - \u041f\u043e\u043a\u0430!!!!!\r\n\"\"\"\r\n# \u0434\u0435\u043b\u0430\u0435\u043c \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e HTML\r\ntext = bs(html, \"html.parser\").text\r\ntext_part = MIMEText(text, \"plain\")\r\nhtml_part = MIMEText(html, \"html\")\r\n# \u043f\u0440\u0438\u043a\u0440\u0435\u043f\u0438\u0442\u044c \u0442\u0435\u043b\u043e \u043f\u0438\u0441\u044c\u043c\u0430 \u043a \u043f\u043e\u0447\u0442\u043e\u0432\u043e\u043c\u0443 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044e\r\n# \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u0438\u043a\u0440\u0435\u043f\u0438\u0442\u0435 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e\r\nmsg.attach(text_part)\r\nmsg.attach(html_part)\r\n# \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u043f\u043e\u0447\u0442\u0443\r\nsend_mail(email, password, FROM, TO, msg)\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0447\u0438\u0442\u0430\u0442\u044c \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u044b\u0435 \u043f\u0438\u0441\u044c\u043c\u0430, \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u043e\u0442 \u044d\u0442\u043e\u0442 \u043a\u043e\u0434: import imaplib import email from email.header import decode_header import webbrowser import os # \u0443\u0447\u0435\u0442\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 username = \"uru07082000@gmail.com\" password = \"password\" def clean(text): # \u0447\u0438\u0441\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0430\u043f\u043a\u0438 return \"\".join(c if c.isalnum() else \"_\" for c in text) # create an IMAP4 class &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/is42-2018.susu.ru\/artyushkinana\/2021\/09\/06\/rabota-s-email\/\" class=\"more-link\">\u0427\u0438\u0442\u0430\u0442\u044c \u0434\u0430\u043b\u0435\u0435<span class=\"screen-reader-text\"> \u00ab\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 EMail\u00bb<\/span><\/a><\/p>\n","protected":false},"author":8,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0},"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/is42-2018.susu.ru\/artyushkinana\/wp-json\/wp\/v2\/posts\/297"}],"collection":[{"href":"https:\/\/is42-2018.susu.ru\/artyushkinana\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/is42-2018.susu.ru\/artyushkinana\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/is42-2018.susu.ru\/artyushkinana\/wp-json\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"https:\/\/is42-2018.susu.ru\/artyushkinana\/wp-json\/wp\/v2\/comments?post=297"}],"version-history":[{"count":1,"href":"https:\/\/is42-2018.susu.ru\/artyushkinana\/wp-json\/wp\/v2\/posts\/297\/revisions"}],"predecessor-version":[{"id":299,"href":"https:\/\/is42-2018.susu.ru\/artyushkinana\/wp-json\/wp\/v2\/posts\/297\/revisions\/299"}],"wp:attachment":[{"href":"https:\/\/is42-2018.susu.ru\/artyushkinana\/wp-json\/wp\/v2\/media?parent=297"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/is42-2018.susu.ru\/artyushkinana\/wp-json\/wp\/v2\/categories?post=297"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/is42-2018.susu.ru\/artyushkinana\/wp-json\/wp\/v2\/tags?post=297"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}