Line | |
---|
1 | ## Script (Python) "mail2student"
|
---|
2 | ##bind container=container
|
---|
3 | ##bind context=context
|
---|
4 | ##bind namespace=
|
---|
5 | ##bind script=script
|
---|
6 | ##bind subpath=traverse_subpath
|
---|
7 | ##parameters=co_name=None,co_email=None,student_email=None,probtype=None,commt=None, action=None
|
---|
8 | ##title=
|
---|
9 | ##
|
---|
10 | # $Id: mail2admin.py 869 2006-11-15 13:46:49Z henrik $
|
---|
11 |
|
---|
12 | from urllib import urlencode
|
---|
13 |
|
---|
14 | mhost = context.MailHost
|
---|
15 | prop = context.portal_properties
|
---|
16 | REQUEST = context.REQUEST
|
---|
17 |
|
---|
18 | # the message format, %s will be filled in from data
|
---|
19 |
|
---|
20 | # message = """
|
---|
21 | # From: %s <%s>
|
---|
22 | # To: %s
|
---|
23 | # Cc: %s
|
---|
24 | # Reply-To: %s
|
---|
25 | # Subject: %s
|
---|
26 | # %s
|
---|
27 | # """
|
---|
28 |
|
---|
29 | #prop.email_from_address should be used for To:
|
---|
30 |
|
---|
31 | # msg = message % (
|
---|
32 | # co_name,
|
---|
33 | # co_email,
|
---|
34 | # student_email,
|
---|
35 | # co_email,
|
---|
36 | # co_email,
|
---|
37 | # probtype,
|
---|
38 | # commt,
|
---|
39 | # )
|
---|
40 | d = {}
|
---|
41 | d['co_name'] = co_name
|
---|
42 | d['co_email'] = co_email
|
---|
43 | d['student_email'] = student_email
|
---|
44 | d['probtype'] = probtype
|
---|
45 | d['commt'] = commt
|
---|
46 |
|
---|
47 | message = """
|
---|
48 | From: %(co_name)s <%(co_email)s>
|
---|
49 | To: %(student_email)s
|
---|
50 | Cc: %(co_email)s
|
---|
51 | Reply-To: %(co_email)s
|
---|
52 | Subject: %(probtype)s
|
---|
53 | %(commt)s
|
---|
54 | """
|
---|
55 |
|
---|
56 | mhost.send(msg % d)
|
---|
57 |
|
---|
58 | args = {}
|
---|
59 | psm = "Your message has been sent!"
|
---|
60 | args['portal_status_message'] = psm
|
---|
61 | if action:
|
---|
62 | url = context.absolute_url() + '/' + action + '?' + urlencode(args)
|
---|
63 | else:
|
---|
64 | url = context.absolute_url() +'?' + urlencode(args)
|
---|
65 | return REQUEST.RESPONSE.redirect(url)
|
---|
66 |
|
---|
Note: See
TracBrowser for help on using the repository browser.