Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

try send html

  • Loading branch information...
commit e8dfc42b67f04e112f104727d5989c6b59a12e23 1 parent 71ebb33
Aleksei Pokrevskiy authored
Showing with 9 additions and 3 deletions.
  1. +9 −3 sendemail.py
View
12 sendemail.py
@@ -1,4 +1,5 @@
# Import smtplib for the actual sending function
+from email.mime.multipart import MIMEMultipart
import smtplib
# Import the email modules we'll need
@@ -6,10 +7,15 @@
# Open a plain text file for reading. For this example, assume that
# the text file contains only ASCII characters.
-fp = open('mail.txt', 'rb')
+html = open('mail.txt', 'rb').read()
+html.close()
# Create a text/plain message
-msg = MIMEText(fp.read())
-fp.close()
+msg = MIMEMultipart('alternative')
+msg['Subject'] = "hello py"
+msg['From'] = 'kilonet@1gb.ru'
+msg['To'] = 'kpdpok@gmail.com'
+
+part1 = MIMEText(html, 'html')
# Send the message via our own SMTP server, but don't include the
# envelope header.
Please sign in to comment.
Something went wrong with that request. Please try again.