From a idea mentionned on this issue #951018: Support for shared hosting environemnts

Allow to use the mailhandler module (shipped by default with Open Atrium) as a inbound email processor. This would simplify the setup and allow configuration on shared hosting environments.

Comments

kyle_mathews’s picture

Version: 6.x-1.0-beta6 » 6.x-1.x-dev
Status: Active » Needs work

This would need to be done as a bridge module that calls ogm's apis when new emails come in. If anyone is seriously interested in this, please start it in a sandbox or on github and add a comment here when it's mature enough to come in. Or perhaps we'll just keep it as a different project.

ilo’s picture

Well, actually, I will. I'm maintaining the mailhandler 1.x-dev branch, and I see no problem at all having this included as part of the mailhandler module.

I've been just redirected to og_mailing_list from mail2og, installed it an found this 'feature' necessary as we don't have full access nor control of the email service, just a spam filtered catch-all address.

Just need some advice.. Calling _og_mailinglist_process_email() for each email recieved that should be inserted is the way to go I guess, but, no documentation at all, you know.. Should I go throug the og_mailing_list_post()? what arguments and how should I put there? Please, drop some light so I can do that bridge and still keep using og_mailing_list in shared hostings.

AFAIK: to keep the token usage, I would copy og_mailinglist_post and pass three arguments:
- $message: raw message as read from the server (currently mailhandler has a copy of it, probably we can skip the mime decoding stuff there).
- $token: I'm pretty sure we don't need this one, as the email is read by mailhandler in Drupal.
- $group_name: this is the name in the email, right?

Being that simple I think we can make use of current mailhandler hooks to make this happen..

kyle_mathews’s picture

Just call _og_mailinglist_process_email($raw_email, $group_name)

og_mailinglist_post() is the callback for /og_mailinglist. How OG Mailinglist generally works is there's a script which gets called whenever an email comes in which is POSTed to the intended Drupal site. But as you pointed out, since you're already in Drupal, there's no need to do that.

So yeah, it should be pretty straightforward to get the receiving part working, just pass in the raw email. The $group_name isn't actually necessary to figure out before hand as there's a regex which will pull it out if necessary.

One problem you might still have however is emails are sent still by making a direct call to sendmail -- see line 860 of og_mailinglist_transport.inc If that's a problem, some help on #911974: Send all emails through PHPMailer removing dependency on having a Sendmail compatible server would be much appreciated.

ilo’s picture

oh yes, I saw it. Currently Mailhandler uses Drupal's mail facility to send email replies. I think that should be the way to get rid of the sendmail command.

kyle_mathews’s picture

Sending email through Drupal's mail function won't work. OGM creates emails completely from scratch so that it can pass along received emails exactly as received -- something Drupal's mail function won't support.

jvieille’s picture

Any progress on this?
I think the proposed way for handling inbound email is both complex and only works for one site per server.

mahfiaz’s picture

jvieille, why exactly are you interested in this? Is it simplified setup (as the first post) or are you after some extra features?

jvieille’s picture

I am interested in this for the 2 reason that originated this report:
1) simplify the setup (which is not "required")
2) allow to operate on multiple sites implemented on the same server.
But I may be wrong on the second point, my understanding is that the MTA has to be configured for a specific domain. If it is the case, then it is (1) and I shall be more resilient before the "complex" setup ...

mahfiaz’s picture

Actually the setup when you have root access is not that complex at all.

MTAs can handle multiple virtual domains (just google for it) and so does og_mailinglist (sites_info.php requires an entry per domain).

AFAIK only reasons why one would need mailhandler integration is additional features, e.g to set node published status or CCK fields other than body and attachments.

jvieille’s picture

Thanks for the clarification.
I'll have a more serious look at this.

hanksterr7’s picture

Issue summary: View changes

Unfortunate to see no activity since 10/2012

I agree some integration with mailhandler/feeds would be helpful (although complicated). The main feature of mailhandler that I see is needed is the ability to specify default values for node attributes as nodes are created by inbound email messages (or to specify these values in the inbound email itself). Mailhandler makes this easy. For example, if I define a field "importance" for an Article content type, I would like all Article nodes created by OGM to, by default, set the "importance" value to "minor" as OGM creates an Article node. But if I wanted, I would like the inbound email body to have a line like:

importance: major

which would cause the Article node that is created to have an "importance" value of major. This is especially needed if "importance" is declared to be a required field for the Article content type

Mailhandler/feeds makes that easy to do.

mahfiaz’s picture

Title: Allow inbound email processing via MailHandler module. » Allow inbound email processing via MailHandler module
Version: 6.x-1.x-dev » 7.x-1.x-dev

Are you well familiar with mailhandler?

hanksterr7’s picture

How it works, but not how to re-code it. OGM's been enough of a science project :)

mahfiaz’s picture

Status: Needs work » Postponed

Although it would be nice, it makes things more complex from OGM's perspective. One feature of OGM is that it passes the original emails along almost unchanged (except for the footer and changing a few headers). To keep this functionality one would probably need to catch the mail before MailHandler starts processing it. Maybe it passes the original down the line until the node is created, then one could send the email, I don't know how it works. But it looks quite complex piece of software with all the modules, hooks and things. If someone could point me in the right direction, I'd happily take a look.