[891] | 1 | ## Script (Python) "mail2student"
|
---|
| 2 | ##bind container=container
|
---|
| 3 | ##bind context=context
|
---|
| 4 | ##bind namespace=
|
---|
| 5 | ##bind script=script
|
---|
| 6 | ##bind subpath=traverse_subpath
|
---|
[1595] | 7 | ##parameters=co_name=None,co_email=None,student_email=None,probtype=None,commt=None, action=None
|
---|
[891] | 8 | ##title=
|
---|
| 9 | ##
|
---|
| 10 | # $Id: mail2admin.py 869 2006-11-15 13:46:49Z henrik $
|
---|
| 11 |
|
---|
[1598] | 12 | from urllib import urlencode
|
---|
| 13 |
|
---|
[891] | 14 | mhost = context.MailHost
|
---|
| 15 | prop = context.portal_properties
|
---|
| 16 |
|
---|
| 17 | # the message format, %s will be filled in from data
|
---|
| 18 |
|
---|
| 19 | message = """
|
---|
| 20 | From: %s <%s>
|
---|
| 21 | To: %s
|
---|
| 22 | Cc: %s
|
---|
| 23 | Bcc: %s
|
---|
| 24 | Reply-To: %s
|
---|
| 25 | Subject: %s
|
---|
| 26 | %s
|
---|
| 27 | """
|
---|
| 28 |
|
---|
| 29 | #prop.email_from_address should be used for To:
|
---|
[909] | 30 | REQUEST = context.REQUEST
|
---|
[1595] | 31 |
|
---|
| 32 | #url_tuple = REQUEST.HTTP_REFERER.split('?')
|
---|
| 33 | #if len(url_tuple) == 2:
|
---|
| 34 | # url_tuple[1] ='portal_status_message=Your message has been sent!'
|
---|
| 35 | #else:
|
---|
| 36 | # url_tuple.append('portal_status_message=Your message has been sent!')
|
---|
| 37 | #redirect_url = "?".join(url_tuple)
|
---|
| 38 | #REQUEST.set('rurl', redirect_url) # to see the result in the error log
|
---|
| 39 |
|
---|
[891] | 40 | msg = message % (
|
---|
| 41 | co_name,
|
---|
| 42 | co_email,
|
---|
[1575] | 43 | student_email,
|
---|
[891] | 44 | co_email,
|
---|
[1608] | 45 | 'waeup@saoas.org',
|
---|
[891] | 46 | # 'js@aixtraware.de',
|
---|
| 47 | co_email,
|
---|
| 48 | probtype,
|
---|
| 49 | commt,
|
---|
| 50 | )
|
---|
| 51 | mhost.send(msg)
|
---|
| 52 |
|
---|
| 53 |
|
---|
[1595] | 54 | #REQUEST = context.REQUEST
|
---|
| 55 | #RESPONSE = REQUEST.RESPONSE
|
---|
| 56 | #RESPONSE.redirect(redirect_url)
|
---|
| 57 |
|
---|
| 58 | args = {}
|
---|
| 59 | psm = "Your message has been sent!"
|
---|
| 60 | args['portal_status_message'] = psm
|
---|
[1608] | 61 | if action:
|
---|
| 62 | url = context.absolute_url() + '/' + action + '?' + urlencode(args)
|
---|
| 63 | else:
|
---|
| 64 | url = context.absolute_url() +'?' + urlencode(args)
|
---|
[1595] | 65 | return REQUEST.RESPONSE.redirect(url)
|
---|
| 66 |
|
---|
| 67 |
|
---|
| 68 |
|
---|