Permalink
Browse files

try send html

  • Loading branch information...
1 parent 71ebb33 commit e8dfc42b67f04e112f104727d5989c6b59a12e23 Aleksei Pokrevskiy committed Aug 21, 2011
Showing with 9 additions and 3 deletions.
  1. +9 −3 sendemail.py
View
@@ -1,15 +1,21 @@
# Import smtplib for the actual sending function
+from email.mime.multipart import MIMEMultipart
import smtplib
# Import the email modules we'll need
from email.mime.text import MIMEText
# 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.

0 comments on commit e8dfc42

Please sign in to comment.