Jump to content
  • 0

Email Piping From Mandrill


exception0x876

Question

Hello!

 

I am trying to setup inbound email piping to blesta from Mandrill. I've created a php script that catches posted data from Mandrill and parses it, then invokes "/usr/bin/php <full_path_here>/plugins/support_manager/pipe.php" and passes mail contents to STDIN. However I do not see new tickets created. I've attached an example of parsed mail contents that is passed to pipe.php.

file.txt

Link to comment
Share on other sites

15 answers to this question

Recommended Posts

  • 0

Error, I tested but can not really remember me, from memory all was working with blesta:

 

- at mandrill create an email box (or sender) by blesta support department

 

- at your domain name & dns editor add a txt records mandril tell you for allowed sender ip & domain, for me it was like this:

 

mandrill._domainkey

 

v=spf1 a mx ip4:108.161.139.8 include:spf.mandrillapp.com ~all

 

- at your domain name & dns editor add a txt records mandril tell you for DKIM , for me it was like this:

 

v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3DQ........................;

Link to comment
Share on other sites

  • 0

Thanks for the info serge.

 

Licensecart, I am not sure you understood what I am trying to do and what is not working. Let me explain it a bit more.

 

Here is the script that I have for handling mandrill webhook for inbound mail

<?php

mysql_connect(...);
mysql_select_db(....);
mysql_query('set names "utf8"');

if (isset($_POST['mandrill_events'])) {
        $res = json_decode($_POST['mandrill_events']);
        if (is_array($res))
        foreach ($res as $v) {
                if (is_object($v)) {
                        $p = popen('/usr/bin/php plugins/support_manager/pipe.php', 'w');
                        fwrite($p, $v->msg->raw_msg);
                        fclose($p);
                }
        }
}

The script basically passes the received message as STDIN to /usr/bin/php plugins/support_manager/pipe.php

 

No error is reported from pipe.php, however the ticket is not created in Blesta Support Manager.

Link to comment
Share on other sites

  • 0

I can not remember exactly what I did tested with mandrill, but think just SMTP was fine like licensecart said, no custom code, but you just need appropriate dns record to be the allowed sender, and to collect email just use your smtp/mandrill account detail for the given email, and that's it

Link to comment
Share on other sites

  • 0

I can not remember exactly what I did tested with mandrill, but think just SMTP was fine like licensecart said, no custom code, but you just need appropriate dns record to be the allowed sender, and to collect email just use your smtp/mandrill account detail for the given email, and that's it

Again I have no problem with sending email from blesta using SMTP, it works fine. What I need is the way to collect incoming emails and convert them to blesta tickets, you know like what is piping is made for. It cannot be done using SMTP as SMTP is for sending mail, not receiving it. The only way to receive email is by using webhooks I described above, and for that I need blesta pipe.php script to actually work instead of silently exiting.

Link to comment
Share on other sites

  • 0

Typically with popen you want to use pclose and not fclose. However in my test environment I wrote a simple pipe program and simulator and it did not matter.

Things to try, make sure Blesta debugging is enabled (along with PHP's)

(in config/core.php)

Configure::set("System.debug", true);
and that the path to pipe program is correct. You should try using the full path in your code above. You may also want to try and add a shebang to plugins/support_manager/pipe.php. Use something like

#!/bin/env php -q
should do it. Of course, also make sure Blesta department is setup to correctly handle piping.

-Adam

Link to comment
Share on other sites

  • 0

Adam, thank you for your advice. I provided the php script just as an example so it is easier to understand what I am trying to achieve. Basically the following does not work

 

cat message.txt | /usr/bin/php plugins/support_manager/pipe.php

 

You can download message.txt in my 1st post attachment.

 

I have set a support department in Blesta and set Email Handling to Piping there.

 

I will try to turn on debug option you mentioned and report the results.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...