#!/usr/bin/python # On 'send' click in main root window import commonhtml from externs import mailconfig commonhtml.editpage(kind='Write', headers={'From': mailconfig.myaddress})
quoted += '%s: %s\n' % (hdr, dechdr) quoted += '\n' + getfield(form, 'text') quoted = '\n' + quoted.replace('\n', '\n> ') return quoted form = cgi.FieldStorage() # parse form or URL data user, pswd, site = commonhtml.getstandardpopfields(form) pswd = secret.decode(pswd) try: if form['action'].value == 'Reply': headers = {'From': mailconfig.myaddress, # 3.0: commonhtml decodes 'To': getfield(form, 'From'), 'Cc': mailconfig.myaddress, 'Subject': 'Re: ' + getfield(form, 'Subject')} commonhtml.editpage('Reply', headers, quotetext(form)) elif form['action'].value == 'Forward': headers = {'From': mailconfig.myaddress, # 3.0: commonhtml decodes 'To': '', 'Cc': mailconfig.myaddress, 'Subject': 'Fwd: ' + getfield(form, 'Subject')} commonhtml.editpage('Forward', headers, quotetext(form)) elif form['action'].value == 'Delete': # mnum field is required here msgnum = int(form['mnum'].value) # but not eval(): may be code fetcher = mailtools.SilentMailFetcher(site, user, pswd) fetcher.deleteMessages([msgnum]) commonhtml.confirmationpage('Delete') else:
#!/usr/local/bin/python3 #-*- coding: utf-8 -*- # Глава 15. Сервер PyMailCGI. # Отправка почты по SMTP. # Страница составления сообщений. # Пример 16.3 (Лутц Т2 стр.602) """ # ---------------------------------------------------------------------------- # Вызывается щелчком на ссылке 'send' в главной странице: отображает страницу составления нового сообщения # ---------------------------------------------------------------------------- # """ import commonhtml from externs import mailconfig commonhtml.editpage(kind='Write', headers={'From': mailconfig.myaddress})