Вот код:
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
def send_mail():
with open("desktop.cfg") as file:
text = file.readline()
login = "*****@yandex.ru"
password = "********"
url = "smtp.yandex.ru"
toaddr = "****@desoz.com"
msg = MIMEMultipart()
msg['Subject'] = "Open File"
msg['From'] = "****@yandex.ru"
body = str(text)
msg.attach(MIMEText(body, msg.as_string()))
try:
server = smtplib.SMTP_SSL(url, 465)
except TimeoutError:
print("No connect")
server.login(login, password)
server.sendmail(login, toaddr, msg.as_string())
server.quit()
def main():
send_mail()
if __name__ == "__main__":
main()
Выводит такую ошибку:
email.errors.HeaderParseError: header value appears to contain an embedded header: 'text/Content-Type: multipart/mixed; boundary="\\"===============7228160787276040574==\\"\nMIME-Version: 1.0\nSubject: Open File\nFrom: ******@yandex.ru\n--===============7228160787276040574==\n--===============7228160787276040574==--"; charset="us-ascii"'
Хелп, как это можно исправить? Мне нужно прочитать файл и отправить текст из него по мейлу ко мне на адресс.
Добавлено: в файле такой текст:
00:00.0 Host bridge: Intel Corporation Celeron N3350/Pentium N4200/Atom E3900 Series Host Bridge (rev 0b)
00:00.1 Signal processing controller: Intel Corporation Device 5a8c (rev 0b)
00:02.0 VGA compatible controller: Intel Corporation Celeron N3350/Pentium N4200/Atom E3900 Series Integrated Graphics Controller (rev 0b)
00:0e.0 Audio device: Intel Corporation Celeron N3350/Pentium N4200/Atom E3900 Series Audio Cluster (rev 0b)
00:0f.0 Communication controller: Intel Corporation Celeron N3350/Pentium N4200/Atom E3900 Series Trusted Execution Engine (rev 0b)
00:12.0 SATA controller: Intel Corporation Celeron N3350/Pentium N4200/Atom E3900 Series SATA AHCI Controller (rev 0b)
00:13.0 PCI bridge: Intel Corporation Celeron N3350/Pentium N4200/Atom E3900 Series PCI Express Port A #1 (rev fb)
00:13.1 PCI bridge: Intel Corporation Celeron N3350/Pentium N4200/Atom E3900 Series PCI Express Port A #2 (rev fb)
00:14.0 PCI bridge: Intel Corporation Celeron N3350/Pentium N4200/Atom E3900 Series PCI Express Port B #1 (rev fb)
00:15.0 USB controller: Intel Corporation Celeron N3350/Pentium N4200/Atom E3900 Series USB xHCI (rev 0b)
00:16.0 Signal processing controller: Intel Corporation Celeron N3350/Pentium N4200/Atom E3900 Series I2C Controller #1 (rev 0b)
00:17.0 Signal processing controller: Intel Corporation Celeron N3350/Pentium N4200/Atom E3900 Series I2C Controller #5 (rev 0b)
00:1f.0 ISA bridge: Intel Corporation Celeron N3350/Pentium N4200/Atom E3900 Series Low Pin Count Interface (rev 0b)
00:1f.1 SMBus: Intel Corporation Celeron N3350/Pentium N4200/Atom E3900 Series SMBus Controller (rev 0b)
01:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL810xE PCI Express Fast Ethernet controller (rev 07)
02:00.0 Network controller: Qualcomm Atheros QCA9565 / AR9565 Wireless Network Adapter (rev 01)
03:00.0 3D controller: NVIDIA Corporation GK107M [GeForce 810M] (rev a1)