I've created a custom mailer script for PloneFormGen, (what I have below is a rough example, my script does a lot more) because of this I couldn't use the built in mail adapter.
from Products.CMFCore.utils import getToolByName
mailhost = getToolByName(ploneformgen, 'MailHost')
import logging
logger = logging.getLogger("mailer-logger")
token_url = "mysite.com/myurl"
message = ""
subject = "Hey Peeps"
sender = "info@mysiteexample.com"
recipient = request.form.get("replyto", None)
if recipient:
mailhost.send(message,
recipient,
sender,
subject=subject, charset="utf-8")
When my form calls the script I get the following in the traceback:
- <PythonScript at /Plone/myform/custom-mailer/custom-mailer>
- Line 42
Unauthorized: You are not allowed to access 'send' in this context
2016-02-21 17:54:03 WARNING plone.protect error parsing dom, failure to add csrf token to response for url http://mysite:8081/Plone/myform/fg_base_view_p3