Jump to:
| Project: | Mailhandler |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | ilo |
| Status: | needs work |
Issue Summary
Drush implementation using this patch allows us to separate the frequency of mailhandler retrievals from the frequency of running Drupal cron.
This feature request was inspired by #392782: Retrieve content automatically w/out running cron? (Every 5 mins cron seems too much). Some sites wish to be able to run Mailhandler frequently, and cron infrequently.
Files attached here are identical to the files in comment #12 on that issue.
By mailhandler.drush.inc in the mailhandler directory* you can use it thus:
## show available mailboxes
$ drush mailhandler list
Available mailhandler mailboxes: test1@example.org, test2@example.org
## retrieve all mailboxes
$ drush mailhandler retrieve
Retrieving mail for test1@example.org
Retrieving mail for test2@example.org
## retrieve a specific mailbox
$ drush mailhandler retrieve test2@example.org
Retrieving mail for test2@example.orgTo check all mailhandler mailboxes at a ten minute interval, use a system cron entry like this:
*/10 * * * * /path/to/drush mailhandler retrieveAttached ZIP contains mailhandler.drush.inc for easy installation. Patch is against CVS DRUPAL-6--1.
| Attachment | Size |
|---|---|
| 392782-mailhandler_drush_retrieve.patch | 3.11 KB |
| mailhandler-drush-inc.zip | 1.67 KB |
Comments
#1
What I meant to say was,
By placing mailhandler.drush.inc in the mailhandler directory* you can use it thus:
...
* Or if you want to keep your mailhandler module install super-clean, ...
You can put your drush command file in a number of places:
- In a .drush folder in your HOME folder. Note, that you have
to make the .drush folder yourself.
- Along with one of your existing modules. If your command is
related to an existing module, this is the preferred option.
- In a folder specified with the include option (see above).
- In /path/to/drush/commands (not a Smart Thing, but it would work).
... but then you'll probably need to remove the command file if Mailhandler starts shipping its own copy, as I hope it will.
#2
A couple of things which came up while implementing this:
drush mailhandler retrieveruns each ten minutes, then the mailbox may be accessed twice at :00. There are other situations where this might arise, eg someone doing a manual retrieve while cron is running, or two admins simultaneously retrieving. So locking to prevent duplicate retrievals may be a consideration.mailhandler_cron_retrieve()could return$retrieved_messages, at which point Drush could report the number of successful messages retrieved. (The number of successful node / comment submissions would also be interesting to see here, but that's notmailhandler_cron_retrieve()'s job.Neither of these are required to be fixed for this issue IMO, but they might be worth their own issues if the Mailhandler team thinks they are worth raising.
#3
subscribing
#4
The (now postponed) issue #606018: Provide argument to drush cron allowing specific cron hooks to be run was inspired by this issue, but the patch here allows finer control of mailhandler, as it makes it possible to handle mailboxes individually as well.
#5
Looks neat, any chance of getting this included in the next release? While the same functionality (running Mailhandler independently of cron) can be achieved via Elysia cron, I think implementing Drush hooks could still be useful for people.
#6
This issue is marked "needs review". That means there is no chance of this being included in the next release ... unless someone reviews it. I can't review it because it's my code (well, I guess I can poke holes in it, see #2).
People who wish to see this code in an upcoming release should follow the instructions at the top (preferably via patching their installed module), then report back on either -
Once some people have done that, and maybe even marked this issue RTBC, the maintainer is able to consider its inclusion in the next release.
EDIT: That said, I'd like to thank you kindly for your enthusiasm. I hope that my comment above will be interpreted in good humour, not as any kind of personal attack, and that it will encourage any readers who want issues resolved to take a practical and engaged approach to making it happen.
I think a recent comment by @dries really sums it up (not just in regard to patches, though) -
#7
Mailhandler 2.0 (http://github.com/ianshward/Mailhandler-2.0) will use Feeds as a framework for importing mail. There's a patch in the queue for drush integration with feeds here http://drupal.org/node/608408 which would cover Mailhandler 2.0. That said, there's still some work to be done to get 2.0 stable and released.
#8
Bumping, so I can work on this as soon as I could.