Custom Email Header

  • Posts: 12
  • Thank you received: 1
4 weeks 1 day ago #347875

-- HikaShop version -- : 4.7
-- Joomla version -- : 4.2.3
-- PHP version -- : 8.1.11

I commonly include a custom email header in emails sent via Joomla's Mail class (e.g.: "x-customname: sample;", which are added by using PhpMailer's ->AddCustomHeader method on Joomla's Mail class, which extends PhpMailer). I'd like to include a similar header in Hikashop's generated emails, mostly to help me use rules to sort my incoming mail, but partly to do things like identifying which of HikaShop's templates was used or including custom data from custom plugins I occasionally write.

I know I could modify HikaShop's mail object, but is there some kind of override method or plugin process that wouldn't be overridden by updates?

Could you add this as a possible feature to include in a future update?

Please Log in or Create an account to join the conversation.

  • Posts: 77751
  • Thank you received: 12263
  • MODERATOR
4 weeks 1 day ago #347877

Hi,

It's already possible. You can implement the onBeforeMailSend(&$mail, &$mailer) event :
www.hikashop.com/support/documentation/6...tml#onBeforeMailSend
in $mail, you'll have the data of the email, and in $mailer, you'll have the Joomla Mail class with the AddCustomHeader function.
So you can just create a plugin of the group "hikashop" with that event and call AddCustomHeader on $mailer based on the data in $mail.

Please Log in or Create an account to join the conversation.

  • Posts: 12
  • Thank you received: 1
3 weeks 1 day ago #348058

Thanks. I didn't know if the $data value provided to the plugin was an actual Mail object or just a structure holding the requisite data.

Please Log in or Create an account to join the conversation.

Time to create page: 0.053 seconds
Powered by Kunena Forum