Mautic Community Forums

Cannot get a lead in EmailSubscriber

Hello everyone! Please help me understand some thing…

I have EmailSubscriber class with method

Code:
static public function getSubscribedEvents() { return [ EmailEvents::EMAIL_ON_SEND => array('onEmailGenerate', 0), EmailEvents::EMAIL_ON_DISPLAY => array('onEmailGenerate', 0) ]; }
Method 'onEmailGenerate' successfully subscribed these actions so I can do simple manipulations with email content
for example =
Code:
$content = str_replace('{find}', 'replacement', $content);
But I really need to insert into email some info of lead (or contact) which email is sent to. Please help to get this info
Code:
/** * @param EmailSendEvent $event */ public function onEmailGenerate(EmailSendEvent $event) { // Get content $content = $event->getContent();
    if(strpos($content, '{someleaddata_list}') !== false)
    {

        $leadData = $event->getLead();  // this method returns null even email was sent to real lead email..</div>
Thank you!

Hello everyone! Please help me understand some thing…
I have EmailSubscriber class with method

    static public function getSubscribedEvents()
    {
        return [
            EmailEvents::EMAIL_ON_SEND    => array('onEmailGenerate', 0),
            EmailEvents::EMAIL_ON_DISPLAY => array('onEmailGenerate', 0)
        ];
    }

Method ‘onEmailGenerate’ successfully subscribed these actions so I can do simple manipulations with email content
for example = $content = str_replace('{find}', 'replacement', $content);
But I really need to insert into email some info of lead (or contact) which email is sent to. Please help to get this info

[code]/**
* @param EmailSendEvent $event
*/
public function onEmailGenerate(EmailSendEvent $event)
{
// Get content
$content = $event->getContent();

    if(strpos($content, '{someleaddata_list}') !== false)
    {

        $leadData = $event->getLead();  // this method returns null even email was sent to real lead email..

[/code]
Thank you!