Some platforms have rl_completion_append_character but not rl_completion_suppress_append.
[python.git] / Doc / includes / email-alternative.py
blob82e3ffa3b3a09a0bfa9cef66ccdb208975c06f91
1 #! /usr/bin/python
3 import smtplib
5 from email.mime.multipart import MIMEMultipart
6 from email.mime.text import MIMEText
8 # me == my email address
9 # you == recipient's email address
10 me = "my@email.com"
11 you = "your@email.com"
13 # Create message container - the correct MIME type is multipart/alternative.
14 msg = MIMEMultipart('alternative')
15 msg['Subject'] = "Link"
16 msg['From'] = me
17 msg['To'] = you
19 # Create the body of the message (a plain-text and an HTML version).
20 text = "Hi!\nHow are you?\nHere is the link you wanted:\nhttp://www.python.org"
21 html = """\
22 <html>
23 <head></head>
24 <body>
25 <p>Hi!<br>
26 How are you?<br>
27 Here is the <a href="http://www.python.org">link</a> you wanted.
28 </p>
29 </body>
30 </html>
31 """
33 # Record the MIME types of both parts - text/plain and text/html.
34 part1 = MIMEText(text, 'plain')
35 part2 = MIMEText(html, 'html')
37 # Attach parts into message container.
38 # According to RFC 2046, the last part of a multipart message, in this case
39 # the HTML message, is best and preferred.
40 msg.attach(part1)
41 msg.attach(part2)
43 # Send the message via local SMTP server.
44 s = smtplib.SMTP('localhost')
45 # sendmail function takes 3 arguments: sender's address, recipient's address
46 # and message to send - here it is sent as one string.
47 s.sendmail(me, you, msg.as_string())
48 s.quit()