#! /usr/bin/env python3
# -*- coding: utf-8 -*-
import socks, socket
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from bs4 import BeautifulSoup as bs
email = "почта"
password = "пароль"
FROM = email
TO = "кому"
subject = "test"
msg = MIMEMultipart("alternative")
msg["From"] = FROM
msg["To"] = TO
msg["Subject"] = subject
html = """
Тестовое <b>сообщение</b>.
"""
text = bs(html, "html.parser").text
text_part = MIMEText(text, "plain")
html_part = MIMEText(html, "html")
msg.attach(text_part)
msg.attach(html_part)
def send_mail(email, password, FROM, TO, msg):
#вот тут подключась к прокси тора
socks.set_default_proxy(socks.SOCKS5, '127.0.0.1', 9050)
socket.socket = socks.socksocket
server = smtplib.SMTP("smtp.live.com", 587)
server.starttls()
server.login(email, password)
server.sendmail(FROM, TO, msg.as_string())
print('norm')
server.quit()
send_mail(email, password, FROM, TO, msg)