Support » Plugin: WP ERP - Complete WordPress Business Manager with HR, CRM & Accounting Systems for Small Businesses » Email piping not working with transactional email service

  • Resolved cunnningstunts

    (@cunnningstunts)


    I can send emails out, but nothing comes back in.

    I’ve set the IMAP Connection up in the Email Connectivity settings area (under CRM), and the connection test is successful.

    Running the cronjob manually, I noticed an error logged for functions-customer.php (line 3309) where $imap_options[‘schedule’] was used in a conditional and wasn’t defined. So I added an isset() for it there to clear that up, but that’s not why the emails aren’t piping in.

    Inside this function (erp_crm_check_new_inbound_emails) there’s an if condition that always fails:

    if ( isset( $email['headers']['References'] ) && preg_match( '/<' . $email_regexp . '>/', $email['headers']['References'], $matches ) ) {

    The $email_regexp variable is set above as:

    $email_regexp = '([a-z0-9]+[.][0-9]+[.][0-9]+[.][r][1|2])@' . $_SERVER['HTTP_HOST'];

    So I checked the $email[‘headers’][‘References’] variable for the test messages I’m working with and the values were nothing like what that condition is looking for. So now I know what it is: I’m using a third party service for transactional emails (Postmark), and the header data being sent out by the ERP system is being lost somewhere in the process.

    By default, all my WP email goes out via the Postmark api using their WP plugin. I thought that might be the issue, so I changed ERP to send out via SMTP in the Email settings – same problem.

    So it seems like your inbound email functionality is a bit flimsy.. and looks like it will only pipe in emails that are replies to emails that are sent from ERP in the first place? that doesn’t sound great.. what if a customer creates a new email to this address?

    Wouldn’t it be better to simply match the sender and the subject when piping in emails?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support Mehedi Hasan

    (@thebengalboy)

    Hello @cunnningstunts

    We are already concerned about the issue with the inbound email. We are working to fix this as soon as we can.

    Thanks for your understanding 🙂

    Regards,

    Plugin Support Mehedi Hasan

    (@thebengalboy)

    Hello @cunnningstunts

    We have already fixed the inbound email issue. You can see the commit here-> https://github.com/wp-erp/wp-erp/issues/787

    However, you can try the development version from the GitHub if you like to get the fixes urgently.

    Thanks

    Thanks for the reply, but this isn’t fixed in the latest dev version you have on GitHub.

    Looking at that commit, I can’t see how the issue would be fixed. The isset() is added, which would clear up the conditional error I mentioned, but the area where the actual problem is remains untouched.

    So if I add an else to the if statement that’s checking the $email[‘headers’][‘References’] variable, to log the error, like so:

    else {
        error_log($email['headers']['References']);
    }

    This is what I get in the logs when I run the cron job:

    <c29feb85-f350-49c6-938f-70fc7e6e64ac@mtasv.net>
    <0f574859-c901-484c-a431-9e5cb61c0479@mtasv.net>
    <0f574859-c901-484c-a431-9e5cb61c0479@mtasv.net>

    Those are my test email replies.

    Like I said above, your code is checking for specific content in the email header, which doesn’t exist. I can only guess this content is added by ERP when sending email out, but when using a transactional email service (like most people should be) that info is stripped out. It would also mean that any emails sent by customers that aren’t a reply to a system generated email, would be ignored anyway, which for me makes your whole email system useless.

    To me, a much better way to check where new emails should be piped-in would be to analyse the actual content of the email – sender email address and subject.

    Plugin Support Mehedi Hasan

    (@thebengalboy)

    Hello @cunnningstunts

    The following condition returns true value as we tested after hearing from you:

    if ( isset( $email['headers']['References'] ) && preg_match( '/<' . $email_regexp . '>/', $email['headers']['References'], $matches ) ) {

    May I know in which cases you have tried? Yes, it was not working before the last commit which included the fixes for the inbound email.

    Thanks

    Hi,

    Here’s one of my test emails as an example:

    $email['headers']['References'] = '<c29feb85-f350-49c6-938f-70fc7e6e64ac@mtasv.net>';
    $email_regexp = '([a-z0-9]+[.][0-9]+[.][0-9]+[.][r][1|2])@' . $_SERVER['HTTP_HOST'];
    if ( isset( $email['headers']['References'] ) && preg_match( '/<' . $email_regexp . '>/', $email['headers']['References'], $matches ) ) {
     echo 'nope';
    }
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Email piping not working with transactional email service’ is closed to new replies.