XF 2.2 Integrating into email mailer

stromb0li

Active member
Is there a way I can extend the mailer so when an email is sent by XenForo for any purpose (either before or after) for any purpose (i.e. password reset, watched thread, DM, activity summary, etc) I can access properties of the message (particularly, the subject).
 
Thank you! I ended up extending queue to try and get closer to the actual sending of the message and that seems to have done the trick!

Cheers!
 
Just be aware that not every message gets sent via the mail queue - some are sent directly.
 
Sorry for double post, but you are exactly correct, I'm starting to see which methods send mail directly; password reset being one of them. When extending the class for setContent, how do execute my setContent method after setContent happens? I'd prefer to not copy the code out of the Mail.php file into the setContent method of my class, then add the few lines I need thereafter.
 
Just call the parent first.

PHP:
public function setContent($subject, $htmlBody, $textBody = null): Mail
{
    $mail = parent::setContent($subject, $htmlBody, $textBody);

    // ... whatever you need to do

    return $mail;
}
 
Just call the parent first.

PHP:
public function setContent($subject, $htmlBody, $textBody = null): Mail
{
    $mail = parent::setContent($subject, $htmlBody, $textBody);

    // ... whatever you need to do

    return $mail;
}
Just gave this a go, but it ends up causing an infinite loop since it triggers itself when calling the parent :(
 
You’d have to post the full approach you’re using, calling a parent method won’t result in an infinite loop. Virtually all method extensions in every add-on call the parent method (it’s important to do so for add-on interoperability).
 
Nevermind, this was user error on my part.

Fail Patrick Star GIF by SpongeBob SquarePants
 
Top Bottom