server/scripts/register/confirm.py

57 lines
2.0 KiB
Python
Raw Normal View History

#!/usr/bin/env python
2002-04-07 13:42:27 +02:00
# this script picks all NEW users from the database, (subscribed through
# the web interface), and sends them their customer-id and password
# if the mail was sent cuccessfully, it sets the user to the 'WAITING'
# state, meaning that we wait for his confirmation.
import sys
import MySQLdb
import smtplib
dbname=sys.argv[1]
db = MySQLdb.connect(db=dbname)
From="accounts@vinyambar.de"
server=smtplib.SMTP('localhost')
cursor=db.cursor()
2002-03-14 20:30:11 +01:00
records=cursor.execute("SELECT u.id, u.password, u.email "+
"from users u "+
"where u.status='NEW'")
2002-03-14 20:30:11 +01:00
while records>0:
records = records - 1
2002-03-14 20:30:11 +01:00
customerid, passwd, email = cursor.fetchone()
2001-12-30 12:26:56 +01:00
Msg = ("From: "+From+"\nTo: "+email+"\nSubject: Vinyambar Anmeldung angenommen.\n\n"+
2002-03-14 20:30:11 +01:00
"Deine Anmeldung f<>r Vinyambar wurde akzeptiert.\n"
"\n"+
"Kundennummer: " + str(int(customerid)) + "\n"+
"Passwort: " + passwd + "\n" +
2002-03-14 20:30:11 +01:00
"\n" +
2001-11-07 01:45:45 +01:00
"Bitte bewahre diese Mail sorgf<67>ltig auf, da Du deine Kundennummer und das\n"+
"Passwort f<>r das Spiel ben<65>tigst. Solltest Du noch Fragen zu Deiner \n"+
2002-03-14 20:30:11 +01:00
"Anmeldung haben, wende Dich bitte an accounts@vinyambar.de.\n" +
"\n"+
"Die Kundennummer gib bitte bei der <20>berweisung der Spielgeb<65>hren an. \n" +
"Unsere Kontoinformationen lauten:\n" +
" Katja Zedel\n"+
" Kontonummer 1251 886 106 \n"+
" BLZ 500 502 01 (Frankfurter Sparkasse)\n" +
"\n"+
"Zugang zu deinem Konto erh<72>ltst Du mit dem Passowrt auf der Webseite\n"+
" http://www.vinyambar.de/accounts.shtml\n"+
"\n"+
"Das Vinyambar-Team")
2002-04-07 13:42:27 +02:00
now = time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime())
try:
server.sendmail(From, email, Msg)
2002-04-07 13:42:27 +02:00
print "[%s] USER %d - UPDATE: status='WAITING' " % (now, customerid)
update=db.cursor()
2002-04-07 13:42:27 +02:00
update.execute("UPDATE users set status='WAITING' WHERE id="+
str(int(customerid)))
except:
2002-04-07 13:42:27 +02:00
print "[%s] USER %d - ERROR: could not send to %s: %s " % (now, customerid, email, sys.exc_indo())
2002-03-14 20:30:11 +01:00
sys.exit()