PloneFormGen and fail-safe email send

991 views Asked by At

I'd like to have a PloneFormGen form which both

  • Writes the entry to database for CSV export

  • Sends out email

Is it so that if email send fails the transaction is rolled back and also no entry is written? How one can configure PloneFormGen or email output so that the database entry is written and transaction completes even if SMTP fails?

1

There are 1 answers

0
Laurence Rowe On BEST ANSWER

Send with immediate=True and catch exceptions:

    try:
        self.context.MailHost.send(root.as_string(), immediate=True)
    except Exception as e:
        log = logging.getLogger("MailDataManager")
        log.exception(e)