How to stop Inbound mails creating a case for Email Delivery Failure Notifications?

Hi,

I have a gmail mailbox setup as Inbound Group Mailbox in Sugar , its setup to create Cases automatically. I have a problem of cases being created for bounced back emails such as the Email Delivery Failure notification emails, which we don't want to, does anyone have any suggestions/ answers based on a similar experience? Please let me know.

Note: The SMTP used for outgoing emails from sugar uses Amazon SES(Simple Email Service) 

Regards,
Vijay

  • Hi Vijay

    There are options either to adjust the OOTB behavior or just delete undesired case records created by setting deleted=1
    If you consider the second option, you may do both - describe the logic of the identification of "undesired" case and set the Case.Deleted=1 with Logic Builder for Sugar

    Btw, you may use OOTB Sugar SNIP service - just forward all the inbound emails to the SNIP mailbox and to create leads records instead of cases whenever those emails are archived with SNIP
    I suppose Leads might have better served to Sell purposes than Case module, originally designed for Support (Cases are available in Sugar Serve)

    All the Best,
    Dmytro

    Best Regards,
    Dmytro Chupylka

    integroscrm.com
    We make work in Sugar CRM system faster, more convenient and efficient

  • We had a similar situation and we had to modify the code to achieve this, which is non upgrade safe - so this can be done only in a on-premise installation. There are several ways to do this via code, but we choose a simple approach instead.

    Keep a list of standard subject templates that the email starts with. These can be preg patterns and can be stored in config to ensure they can be added/modified as needed:

    Eg:

    $sugar_config['email_subjects_to_skip'] =
    [
    "^Mail delivery failed",
    "^Delivery Status Notification",
    "^Out of Office",
    ];

    Then in InboundEmail.php - handleAutoResponse (or handleCreateCase if you also want to stop creating cases for such emails), you can add a simple check that checks if the subject starts with one of these (don't check if the subject contains the string - because that could be a real reply or forward), and if it matches, just stop processing them and add helpful logs.

    foreach($emailSubjectsToSkip as $skip) {
    if(preg_match("/$skip/i", $subject)) {
    $GLOBALS['log']->debug("Email with Subject $subject skipped...");
    return false;
    }
    }
  • To make Neeraja's suggestion as upgrade safe. Please follow the below steps.

    Extending the InboundEmail.php to custom path custom/modules/InboundEmail/InboundEmail.php

    require_once('modules/InboundEmail/InboundEmail.php');
    require_once('modules/ACLRoles/ACLRole.php');
    require_once('data/BeanFactory.php');

    class CustomInboundEmail extends InboundEmail{

    //extend your desired function

    }

    and also add the below code in custom/Extension/application/Ext/Include/CustomInboundEmail.php

    <?php

    $objectList['InboundEmail'] = 'InboundEmail';
    $beanList['InboundEmail'] = 'CustomInboundEmail';
    $beanFiles['CustomInboundEmail'] = 'custom/modules/InboundEmail/InboundEmail.php';

    Hope this helps you.