Dynamically attach file to email

  • Posts: 2143
  • Thank you received: 747
3 years 1 month ago #336120

-- HikaShop version -- : 4.4.3
-- Joomla version -- : 3.10
-- PHP version -- : 7.4

Hi,

I need to dynamically attach a file to the "order administrator notification" email.

I imagine I could simply add something like

$xyz->AddAttachment($filename);
to the preload PHP, correct?

I have no trouble setting/getting $filename, but what should "xyz" be?

Thanks for a hint.


Need help with customisations of layouts, style or other site development? PM me!
(Don't forget to turn on "E-mail notification of new messages" )

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
3 years 1 month ago #336125

Hi,

You should be able to do it like that:

$attachment = new stdClass();
$attachment->filename = $filename;
$mail->attachments = array($attachment);

The following user(s) said Thank You: lousyfool

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

  • Posts: 2143
  • Thank you received: 747
3 years 1 month ago #336145

Hi Nicolas,

Excellent -- works great! And with this in hand it was easy to attach multiple files, too... :)

Merci mille fois!


Need help with customisations of layouts, style or other site development? PM me!
(Don't forget to turn on "E-mail notification of new messages" )
The following user(s) said Thank You: nicolas

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

Time to create page: 0.061 seconds
Powered by Kunena Forum