PloneFormGen

Description

PloneFormGen is a contentish editor for creating Plone forms through Plone edit interface.

Fail-safe email sending

By default if SMTP server rejects the message send by PloneFormGen the page will crash with an exception. Possible reasons for SMTP failure are

  • SMTP server is down
  • SMTP server is overloaded
  • SMTP server spam protection is giving false positives for your email sending attempts

If you have a situation where gathering the data is critical the following process is appropriate

  • Use save data adapter to save results
  • Use a custom email sender script adapter to send email and even if this step fails then the data is saved and no exception is given to the user

Example PloneFormGen script adapter (using proxy role Manager):

# -*- coding: utf-8 -*-
from Products.CMFCore.utils import getToolByName

# This script will send email to several recipients
# each written down to its own email field
# whose id starts with "email-"
emails = []

for key in fields:
  if key.startswith('email-'):
    if fields[key] != '':
      emails.append(fields[key])


mailhost = getToolByName(ploneformgen, 'MailHost')

subject = "Huuhaa"

# Custom message with a name filled in
message = u"""Hello,

Thanks for participating %s !
Cheers,
http://www.opensourcehacker.com
""" % (fields['etunimi'])

source = "info@opensourcehacker.com"

for email in emails:
  try:
    mailhost.secureSend(message, email, source, subject=subject, subtype='plain', charset="utf-8", debug=False, From=source)
  except Exception:
    pass



Edit this document

The source code of this file is hosted on GitHub. Everyone can update and fix errors in this document with few clicks - no downloads needed.

  1. Go to PloneFormGen on GitHub.
  2. Press Fork and edit this file button.
  3. Edit file contents using GitHub's text editor in your web browserm
  4. Fill in the Commit message text box at the end of the page telling why you did the changes. Press Propose file change button next to it when done.
  5. On Send a pull request page you don't need to fill in text anymore. Just press Send pull request button.
  6. Your changes are now queued for review under project's Pull requests tab on Github.

For basic information about updating this manual and Sphinx format please see Writing and updating the manual guide.