[schooltool-dev] Blocked mail delivery with zope.sendmail
Marius Gedminas
marius at pov.lt
Thu Oct 16 18:13:57 EDT 2008
On Thu, Oct 16, 2008 at 03:28:58PM -0400, Alan Elkner wrote:
> 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"
This pathname is relative to the current working directory, which may
cause problems.
> 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)
Or you could os.kill(int(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.
It doesn't sound plausible. For one, zope.sendmail shouldn't write to
stderr (unless your zope.conf says to log something there). Also, if
the stderr file descriptor is closed, the process would not block but
would get an IOError (with errno.EPIPE).
> That might explain why it
> works just fine if I start it directly from a terminal and leave that
> terminal up.
Have you checked the log files?
> Does anyone have a suggestion for why this may be happening?
Marius Gedminas
--
We'll show a small example here with one user calling another. (Under
international treaties describing technical papers these users must be called
"Alice" and "Bob".)
-- Anthony Baxter
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.schooltool.org/pipermail/schooltool-dev/attachments/20081017/eacf7dc6/attachment.pgp
More information about the Schooltool-dev
mailing list