Accessing data external to MailWizz for use in outgoing mails?

Colin

New Member
Just after a bit of guidance really. In some cases I'd like to access small amounts of data from our databases to personalise outgoing mails. The data would be different for each outgoing email address. Is there an existing way to do that, or could I write a hook or filter to do it?

Colin
 

twisted1919

Administrator
Staff member
Yup, there's a hook for this.
There is this filter hook: console_command_send_campaigns_before_send_to_subscriber which allows you to modify the email params right before sending the email.
PHP:
Yii::app()->hooks->addFilter('console_command_send_campaigns_before_send_to_subscriber', function($emailParams, $campaign, $subscriber, $customer, $server){
    // inspect emailParams array
    // ...
    
    
    // make sure you return the array of data
    return $emailParams;
});
in this case, the email params array is defined as:
PHP:
$emailParams = array(
            'to'              => array($emailAddress => $toName),
            'subject'         => trim(!empty($emailSubject) ? $emailSubject : $campaign->subject),
            'body'            => trim($emailContent),
            'plainText'       => trim($emailPlainText),
        );
so you can alter the subject / body / plain text per subscriber.
 
Top