Initial Revision
[ohcount] / test / src_dir / py1.py
1 # -*- coding: utf-8 -*-
2 # Python
3
4 # Suppose you want to spam your friend, and you have lots of
5 # friends. The solution is to write a program to do it. After a gander
6 # at python docs, one easily found the module for the job.
7 # see http://python.org/doc/2.3.4/lib/SMTP-example.html
8
9 # the code is a bit long with the command line, but the key lies at
10 # the bottom four lines. The gist is this:
11
12 ####### test: strings - nonsense code follows
13 "\"
14 # still in string
15 "
16 '\'
17 # still in string
18 '
19 ####### test done
20 import smtplib
21
22 smtpServer='smtp.yourdomain.com';
23 fromAddr='xah@xahlee.org';
24 toAddr='xah@xahlee.org';
25 text='''Subject: newfound love
26
27 Hi friend,
28
29 long time no write, i have a new manifesto i
30  think it would be of interest for you to peruse.
31  ...
32  '''
33
34 server = smtplib.SMTP(smtpServer)
35 server.set_debuglevel(1)
36 server.sendmail(fromAddr, toAddr, text)
37 server.quit()
38
39 # save this file as x.py and run it.
40 # it should send out the mail.
41
42 # the set_debuglevel() is nice because you see all the interactions
43 # with the smtp server. Useful when you want to see what's going on
44 # with a smtp server.