• Предмет: Информатика
  • Автор: asdasdasdada89
  • Вопрос задан 6 лет назад

мне нужен код на Python который отправляет файл на почту


wgufhdhvdhge: Сколько вам лет?

Ответы

Ответ дал: osijshdjdkeos
1

Відповідь:

# Import smtplib for the actual sending function

import smtplib

# Here are the email package modules we'll need

from email.mime.image import MIMEImage

from email.mime.multipart import MIMEMultipart

# Create the container (outer) email message.

msg = MIMEMultipart()

msg['Subject'] = 'Subject'

me = '[email protected]'

recipient = '[email protected]'

msg['From'] = me

msg['To'] = recipient

# Assume we know that the image files are all in PNG format

for file in pngfiles:

   # Open the files in binary mode.  Let the MIMEImage class automatically

   # guess the specific image type.

   fp = open(file, 'rb')

   img = MIMEImage(fp.read())

   fp.close()

   msg.attach(img)

# Send the email via our own SMTP server.

s = smtplib.SMTP('localhost')

s.sendmail(me, recipient, msg.as_string())

s.quit()

Вас заинтересует