“
Traceback (most recent call last):
File ”EАнтон/проги/питон/Useless/Эксперименты/sender.py", line 47, in <module>
s.sendmail(me, , composed)
File “C:\Python27\lib\smtplib.py”, line 737, in sendmail
raise SMTPDataError(code, resp)
SMTPDataError: (550, ‘your mailer sends invalid headers’)"
код:
import os import sys import smtplib import mimetypes from optparse import OptionParser from email import encoders from email.message import Message from email.mime.audio import MIMEAudio from email.mime.base import MIMEBase from email.mime.image import MIMEImage from email.mime.multipart import MIMEMultipart from email.mime.application import MIMEApplication from email.mime.text import MIMEText from email.header import Header russian = 'windows-1251' me = 'base.base@inbox.ru' you ='user911@gmail.com' outer = MIMEMultipart() outer['Subject'] = Header('Errors', russian) outer['To'] =Header (me, russian) outer['From'] =Header ("Base <" + you +">", russian) path='errorfile.txt' fp = open(path) msg2=MIMEApplication(fp.read()) fp.close() outer.attach(msg2) msg = MIMEText('Errors', 'plain', russian) outer.attach(msg) filename='errorfile.txt' msg2.add_header('Content-Disposition', 'attachment', filename=filename) composed = outer.as_string() user='base.base' password='basebase' s = smtplib.SMTP('smtp.inbox.ru') s.login(user, password) s.sendmail(me, [you], composed) s.quit()