def send_message(_from,to,subject,text,html=None,attachments=None):
if isinstance(to, str):
to = to.split(",")
att = []
msg = EmailMultiAlternatives(subject, text, _from, [], bcc=to)
if html:
msg.mixed_subtype = 'related'
msg.attach_alternative(html, "text/html")
if attachments:
mime = mimetypes.MimeTypes()
for a in attachments:
with open(a,"rb") as f:
content = f.read()
content_type = mime.guess_type(a)[0]
#print ("Attach %s as %s" % (a, content_type))
if content_type:
c1, c2 = content_type.split('/')
else:
c1 = "application"
c2 = "octet-stream"
part = MIMEBase(c1, c2)
fn = os.path.basename(a)
disposition = "attachment"
if html and re.search('cid:'+fn, html):
disposition = "inline"
part.add_header("Content-Disposition", disposition, filename=fn)
part.add_header("Content-ID", '<'+fn+'>')
part.set_payload(content)
encoders.encode_base64(part)
msg.attach(part)
msg.send()
я думаю в таком случае хотя бы письмо прислали, как владельцу домена