AnsweredAssumed Answered

Custom Email.php

Question asked by Tobse on Apr 16, 2015
Latest reply on Apr 20, 2015 by Tobse

I'm using SugarCRM 6.5.17 CE.

I have to modify all emails sent from the Composer at a point of time between

  • when the user clicked on "Send" and
  • when the email is actually sent out.

Therefore I'm looking for an upgrade-safe solution to modify the function email2Send() in modules/Emails/Email.php.

I have created a file custom/modules/Emails/EmailCustom.php to extend the core's Email.php:

class EmailCustom extends Email {

  function email2Send($request) {        // my function override here...      }    }

Then I have added the following lines to custom/Extension/application/Ext/Include/include.ext.php:

$beanList["Emails"] = "Email";  $beanFiles["Email"] = "custom/modules/Emails/EmailCustom.php";

Then I've browsed through the entire Sugar file system and found two more references to modules/Emails/Email.php:

  • modules/EmailMan/testOutboundEmail.php and
  • modules/EmailMan/views/view.config.php

I have copied them to their equivalent locations in custom/modules/... and modified all occurrences of "modules/Emails/Email.php" to "custom/modules/Emails/EmailCustom.php".

Next I've done a Quick Repair & Rebuild.

Unfortunately my function override of email2Send() isn't executed that way. Sugar rather keeps executing modules/Emails/Email.php. If I write my changes into this file temporarily they're executed properly - but this approach isn't upgrade-safe.