Feature Requests
Share ideas, discuss and vote on requests from other users in community
 
This object is in archive! 

More hook options for emails

Julian M. shared this idea 6 years ago
Under Consideration

I'd like to have more options and control over emails that are sent by WHMCS. The EmailPreSend hook is nice, but at the moment, it doesn't solve any problems for me. For example, some more variables could be passed to it, and it would be nice to be able to alter the Subject, To, and From headers. Especially the To header would be important to me. It would allow me to test certain features/emails in a live production environment.

Also, for most hooks, it doesn't seem to be possible to alter variables passed to them. Here's a very simple example of how a hook could be used for this purpose:

    function hook_pre_send_email_demo($vars) {

    $email_template_name = $vars['messagename']; # Email template name being sent

    $relid = $vars['relid']; # Related ID it's being sent for - client ID, invoice ID, etc...

    $merge_fields = array();

    $merge_fields['my_custom_var'] = "My Custom Var";

    $merge_fields['my_custom_var2'] = "My Custom Var2";

    if ($x=='y') $merge_fields['abortsend'] = true; # You can use this return to stop email sending

    $merge_fields['to'] = '[email protected]';

    $merge_fields['subject'] = $vars['subject'] . " (TESTING)";

    $vars = array_merge( $vars, $merge_fields );

    return $vars;

    }

    add_hook( "EmailPreSend", 1, "hook_pre_send_email_demo" );

Comments (3)

photo
1

+1 for this one as soon as you can Please

photo
1

also for incoming emails (Header info) Of course :)

photo
1

+1 i need this feature