Ticket #10735 (assigned Bug)
Can't change default mailhost options in ZMI
Reported by: | eleddy | Owned by: | eleddy |
---|---|---|---|
Priority: | minor | Milestone: | 4.x |
Component: | General | Version: | 4.2 |
Keywords: | 4.0b5, mailhost, upstream | Cc: | eleddy, tonim, frisi |
Description (last modified by esteele) (diff)
Just built 4.0b5. The default is not to have async queuing selected, and the queue directory is defaulted to '/tmp'. After a default install just trying to change the smtp port, the below error throws. Besides the error itself, I don't think any checking should be done on the /tmp directory without the async option selected as well (or make the default directory option be ???).
Anyone with an internal network is going to make changes to the internal mail server as one of their first steps. The workaround is to clear the field and save the changes.
Traceback (innermost last): Module ZPublisher.Publish, line 127, in publish Module ZPublisher.mapply, line 77, in mapply Module ZPublisher.Publish, line 47, in call_object Module Products.MailHost.MailHost, line 187, in manage_makeChanges Module Products.MailHost.decorator, line 26, in method Module Products.MailHost.MailHost, line 298, in _startQueueProcessorThread Module zope.sendmail.delivery, line 229, in setQueuePath Module zope.sendmail.maildir, line 59, in __init__ ValueError: /tmp is not a Maildir folder
Change History
comment:1 Changed 6 years ago by esteele
- Component changed from Unknown to Infrastructure
- Description modified (diff)
comment:2 Changed 6 years ago by eleddy
- Status changed from new to assigned
- Owner set to eleddy
I have a generic setup patch for mail host and the new async attributes, then I propose update CMFPlone/mailhost.xml to override the default '/tmp' directory to be '/tmp/plonemailhost'. Not only does this make things work for defaul installs without the zope.sendmail patch, but its also clearer for admins who are finicky about their /tmp folder and would easily delete something name /tmp/tmp, /tmp/sub, etc...
comment:3 Changed 6 years ago by eleddy
genericsetup bug + patch is at https://bugs.launchpad.net/zope-cmf/+bug/602989 zope.sendmail bug is at https://bugs.launchpad.net/zope2/+bug/602965
comment:4 Changed 6 years ago by davisagli
I'm having trouble reproducing this on Plone trunk currently (with Zope 2.12 trunk, on OS X, trying several different settings for smtp_queue_directory).
I also can't see how this is happening from inspecting the code...the traceback shows it went through line 187 of Products.MailHost.MailHost (in Zope 2.12.7), which is within a "if self.smtp_queue:" block that shouldn't be running given that you said you have the default of async queueing not being enabled.
So does anyone have an explanation for why mailhost.smtp_queue would be True but that not be reflected in the UI?
Elizabeth, can you test this again on trunk and see if it's still a problem for you?
comment:5 Changed 6 years ago by eleddy
Hey David I apologize for not updating but after reporting and tweaking some changes in some of my own code I couldn't replicate the original bug in the same way again so it was likely my fault. However, the bug still remains if you actually click to async queueing checkbox and you already have a /tmp directory, and generic setup is also broken (as seen in the two bugs above). I left the ticket open and assigned to myself as a reminder to follow up as well as a stub for anyone reporting the same error - apologies for not indicating that - I'll be clearer in the future.
comment:6 Changed 6 years ago by davisagli
Ah, okay. Your diagnoses on the remaining issues look correct; thanks for reporting them upstream.
comment:7 Changed 6 years ago by davisagli
- Priority changed from major to minor
- Keywords mailhost, upstream added; mailhost removed
- Milestone changed from 4.0 to 4.x
comment:8 Changed 5 years ago by tonim
- Cc tonim added
May I recommend that the location of the maildir be specified to be somewhere under eg. ${buildout:directory}/var by default? That would imho solve the following problems:
- /tmp is, on all normal systems, erased on startup. If you send a message, and it keeps lingering for some reason (eg. the mail system is not really ready), the mail vanishes upon system shutdown/crash.
- It would highly reduce the likelyhood that there'd be a clash with any other program, making operation almost fool-proof.
comment:10 Changed 3 years ago by frisi
- Cc frisi added
- Version set to 4.2
indeed, buildout/var would make a lot of sense.
currently, you'll have to set the queue_directory in a setuphandler:
portal = getToolByName(context, 'portal_url').getPortalObject() from App import config basedir = config.getConfiguration().environment.get('BUILDOUT_VAR', '/tmp') mailhost = portal.MailHost mailhost.smtp_queue = True mailhost.smtp_queue_directory = os.path.join(basedir, 'mailqueue') mailhost._stopQueueProcessorThread() mailhost._startQueueProcessorThread()
the sample above relys on an environment variable BUILDOUT_VAR set in the buildout configuration
[instance] recipe = plone.recipe.zope2instance ... environment-vars = BUILDOUT_VAR ${buildout:directory}/var/
(any recommendation if it would be better to use App.config.getConfiguration().clienthome instead of the environment variable. the latter allows to use a mailqueue shared by different zope instances. dunno if this is a good idea, though.
it would be great if mailhost.xml would support relative paths such as
<?xml version="1.0"?> <object name="MailHost" smtp_queue="True" smtp_queue_directory="./mailqueue"/>
this should create a directory mailqueue within ${instance:client-home}:
${buildout:directory}/var/<instancepartname>/mailqueue
Tweaking formatting.