I have configured my Mailhost to send all Mails asynchron via Queue. If i start a cronscript via an extra client no mail is sended if the Parameter is immediate=False
(thats required to send via mailqueue). If it set to True
, all works.
If is use the same code snippet in a BrowserView all is fine and the mail is going out. Have anyone an Idea? Perhaps, is the threading the problem, if the instance goes down in the end?
# -*- coding: utf-8 -*-
"""
Command-line script to be run from a ZEO client:
bin/cron-client run cron.py
"""
from zope.component.hooks import setSite
from plone import api
# get the Site Object from the Root Node of ZMI
# here: Mountpoint mysite / PloneInstance plone
site = app.unrestrictedTraverse("mysite/plone")
# Sets the current site as the active site
setSite(site)
with api.env.adopt_user(username="webadmin"):
api.portal.send_email(
recipient="john.doe@test.local",
subject="subject test",
body="body test",
immediate=False)