[schooltool-dev] Blocked mail delivery with zope.sendmail
Alan Elkner
aelkner at gmail.com
Thu Oct 16 15:28:58 EDT 2008
I'm having a problem using zope.sendmail to automatically send emails
from within the schooltool.intervention package. I've added these
configuration lines to the school.zcml file:
<include package="zope.sendmail" file="meta.zcml" />
<mail:smtpMailer
name="intervention"
hostname="localhost" (this substituted with our user's mail server)
port="25"
/>
<mail:queuedDelivery
name="intervention"
permission="schooltool.edit"
queuePath="mail-queue"
mailer="intervention"
/>
and this works under the limited case where I've started schooltool
from within a running terminal instance. When the user does an action
that results in a mail being sent, I see the message in my terminal
that the mail is being sent, and the mail does in fact reach the
user's mail account.
Obviously, I can't start schooltool for the user from within a
terminal session, so I made an init.d script to start/stop/restart it.
It's brain-dead simple and maybe poorly written, but here it is:
import sys
import os
import time
def start():
os.system('cd /opt/schooltool_sandbox/schooltool.stapp2008spring
&& bin/start-schooltool-instance instance > /dev/null &')
time.sleep(3)
def stop():
output = os.popen('ps aux | grep start-schooltool-instance | grep
-v grep').read().strip()
if output:
pid = output.split()[1]
os.system('kill %s' % pid)
def error():
print 'You must supply an argument (start, stop or restart).'
sys.exit()
try:
cmd = sys.argv[1]
except:
error()
if cmd == 'start':
start()
elif cmd == 'stop':
stop()
elif cmd == 'restart':
stop()
start()
else:
error()
sys.exit(0)
This script works for starting, stopping, and restarting schooltool,
but using it causes the emails that get created to get blocked in the
mail-queue/new subdirectory of the instance directory. As the user
uses the app, the emails get created and stored in that directory, but
they don't get delivered, so they stay blocked there. It's only after
I restart schooltool that the emails are sent all at once. Then all
subsequent emails created by the user get blocked once again. For
now, the best I can give the user is an automatic restart of the
server every night and the promise that any email sent from the app
will reach its target the following day.
The best I can guess is that perhaps stderr gets orphaned by the
process that starts schooltool and that zope.sendmail is blocking
trying to write 'email xyz sent' to it. That might explain why it
works just fine if I start it directly from a terminal and leave that
terminal up.
Does anyone have a suggestion for why this may be happening?
More information about the Schooltool-dev
mailing list