29
30
Fork 85

Sent mass mailing to Finnish supporters. Added scripts to SVN.

svn path=/trunk/; revision=24321
Esse commit está contido em:
otto 2012-09-13 09:41:02 +00:00
commit 2cd04c3316
4 arquivos alterados com 171 adições e 1 exclusões

Ver arquivo

@ -2,7 +2,7 @@
// This file is temporary - now I just need so see the db contents
// to develop email confirmation function
//die("This file is for debugging only.");
die("This file is for debugging only.");
$db = new PDO("sqlite:../../../db/support.sqlite");

Ver arquivo

@ -0,0 +1,39 @@
# -*- coding: utf-8 -*-
fromname = "FSFE"
fromaddr = "otto@fsfe.org"
subject = "Tiedote FSFE:n tukijoille Suomessa"
message_body_unwrapped = """
Hyvä FSFE:n tukija!
Kiitos että olet ilmoittautunut tukijaksi sivulla fsfe.org/support
Haluaisitko myös liittyä Fellowship-jäseneksi (http://fellowship.fsfe.org/) tai auttaa FSFE: osallistumalla sen toimintaan (http://fsfe.org/contribute/contribute.fi.html)?
FSFE kaipaa suomalaisten vapaaohjelmistojen käyttäjien ja kehittäjien apua erityisesti nyt, koska
* kuntavaalit lähestyvät ja poliitikoihin vaikuttamiseen pitää panostaa erityisesti nyt
* EU:n parlamentti käsittelee kohta yhtenäispatenttia, johon sisältyy vaara, että ohjelmistopatentit tulevat Suomeenkin
* Patenttisotien, mobiilialustakilpailun ja Windows 8:n myötä tuleva rajoitettu käynnistys -toiminto saattaa rajoittaa Linux-yhteensopivien laitteiden saatavuutta
Lisätietoa näistä aiheista löytyy FSFE:n sivuilta, mm.
http://fsfe.org/news/2012/news-20120907-01.fi.html
http://fsfe.org/campaigns/generalpurposecomputing/secure-boot-analysis.en.html
Suomen paikallisryhmän sivuilta näet mitä FSFE on tehnyt Suomessa viime aikoina:
http://fsfe.org/fi/
Vapaiden ja avoimen lähdekoodin ohjelmistojen käyttäjiä uhkaa ajoittain eräiden monikansallisten yritysten epäreilu toiminta. Tehokkain tapa puolustautua monikansallisia yrityksiä vastaan on tukea omia oikeuksiaan puolustavaa monikansallista järjestöä. Tästä syystä minä olen itsekin mukana FSFE:n toiminnassa.
Auta FSFE: seuraavin tavoin:
1. Kerro tutuillesi FSFE:stä ja suosittele sivua http://fsfe.org/support
2. Liity Fellowship-jäseneksi osoitteessa http://fellowship.fsfe.org/
3. Osallistu FSFE:n toimintaan esimerkiksi graafisena suunnittelijana, kääntäjänä, www-ylläpitäjänä tai tilaisuuksien järjestäjänä. Katso osallistumisvaihtoehtoja sivulla http://fsfe.org/contribute/contribute.fi.html
Kiitos!
Terveisin,
Otto Kekäläinen
FSFE:n Suomen paikallisryhmän koordinaattori
"""

Ver arquivo

@ -0,0 +1,129 @@
#!/usr/bin/python -u
# -*- coding: utf-8 -*-
# TODO: -u does not seem to have any effect
"""
This script does mass mailing using your Google account to avoid being blacklisted.
Please only send proper mass mails, like press releases and not spam.
Usage:
massmailing.py <username@gmail.com> <message file txt> <recipients list csv>
The script must be called with exactly these parameters, no less nor more.
Before execution the script asks for you password interactively.
"""
import sys, getpass, csv, time, smtplib
import textwrap
from email.mime.text import MIMEText
from email.header import Header
def main():
if len(sys.argv) != 4:
print __doc__
sys.exit(0)
else:
# Open connection
username = sys.argv[1]
password = getpass.unix_getpass("Enter password for account " + username + ": ")
server = smtplib.SMTP('smtp.gmail.com:587')
server.starttls()
print "Authenticating " + username
server.login(username,password)
print "Connection opened."
# Read each line fron recipients and send mail
messagefilename = sys.argv[2]
print "Opening " + messagefilename + ".py"
msg = __import__(messagefilename)
addressfilename = sys.argv[3]
print "Opening " + addressfilename
addresses = csv.reader(open(addressfilename, 'r'))
counter = 0
# Now take a pause to send one message to self and check everything is OK
toaddr = msg.fromaddr
toname = "Massmailer"
msg.message_body = ""
lines = msg.message_body_unwrapped.split("\n")
for line in lines:
if len(line) > 78:
w = textwrap.TextWrapper(width=78, break_long_words=False)
line = '\n'.join(w.wrap(line))
msg.message_body += line + "\n"
#msg.message_body = textwrap.fill(msg.message_body_unwrapped, 75, break_long_words=False, replace_whitespace=False)
# withouth replace_whitespace entire message is reflowed and old line breaks forgotten
# with it extra line breaks are added at odd places
massmail(server, msg.fromname, msg.fromaddr, msg.subject, msg.message_body, toaddr, toname)
print "A test message was sent. Check that it is OK."
check = "empty"
while not check in ['y','n']:
check = (raw_input("Can we continue with the mass mailing? (y/n) ")).lower()[0]
if check == "n":
print("Aborting...")
server.quit() # Maybe it closes automatically, but close it to be sure
sys.exit(0)
# OK, start sending
for row in addresses:
if not row:
continue
if row[0]:
firstname = row[0]
if row[1]:
lastname = row[1]
else:
firstname = ""
lastname = ""
toname = firstname + " " + lastname
toaddr = row[2]
sys.stdout.flush()
# Send mail
massmail(server, msg.fromname, msg.fromaddr, msg.subject, msg.message_body, toaddr, toname)
# Wait before sending next
delay = 3
for i in range(delay):
countertext = str(i) + "/" + str(delay) + "s until next"
sys.stdout.write(countertext + '\x08'*len(countertext))
sys.stdout.flush()
time.sleep(1)
counter += 1
# Finally, close the connection
print str(counter) + " mails sent! "
# extra space at the end to overwrite seconds counter
server.quit()
print "Connection closed."
def massmail(server, fromname, fromaddr, subject, message_body, toaddr, toname):
print "Sending to " + toname,
print "<" + toaddr + ">",
text = message_body
# no wordwrap, copy-pasting text from press release to article easier without
# text = textwrap.fill(text, 75)
msg = MIMEText(text, 'plain', 'utf-8')
msg['From'] = str(Header(fromname, 'utf-8')) + ' <' + str(fromaddr) + '>'
if toname:
msg['To'] = str(Header(toname, 'utf-8')) + ' <' + str(toaddr) + '>'
else:
msg['To'] = toaddr
msg['Subject'] = Header(subject, 'utf-8')
# force utf-8 since MIMEText() somehow generates a base64 encoded payload
# instead of utf-8 or quoted-printable
msg.set_payload(text)
msg.replace_header('Content-Transfer-Encoding', '8bit')
server.sendmail(fromaddr, toaddr, msg.as_string())
print "[OK]"
main()

Ver arquivo

@ -0,0 +1,2 @@
Matti,Nurmi,mtnurmi@luukku.com,over quota
Jarmo ,Reinilä,jartre@gmail.coom,.coom
1 Matti Nurmi mtnurmi@luukku.com over quota
2 Jarmo Reinilä jartre@gmail.coom .coom