[Skip to main content](#vessel-content)

#   Dynamically attach file to email

##

- **[lousyfool](/forum/user/28604-lousyfool "View lousyfool's Profile")**
- [![lousyfool's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar28604.jpg)](/forum/user/28604-lousyfool "View lousyfool's Profile") Topic Author
- [ Offline](/forum/user/28604-lousyfool)

Less More

- Posts: 2143
- Thank you received: 746
-
- [](http://www.inphase.one)
-

5 years 1 month ago [\#336120](#336120) by [lousyfool](/forum/user/28604-lousyfool "View lousyfool's Profile")  *[Dynamically attach file to email](/forum/35-orders-management/903279-dynamically-attach-file-to-email#336120 "-- HikaShop version -- : 4.4.3 -- Joomla version -- : 3.10 -- PHP version -- : 7.4  Hi,  I need to dynamically attach a file to the &quot;order administrator notification&quot; email.  I imagine I could simply add something like  to the preload PHP, correct?  I have no trouble setting/getting $filename, but what should &quot;xyz&quot; be?  Thanks for a hint.")* was created by *[lousyfool](/forum/user/28604-lousyfool "View lousyfool's Profile")*

-- 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 Code:

$xyz-&gt;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!](/component/uddeim/?task=new)
(Don't forget to turn on [ "E-mail notification of new messages"](/component/uddeim/?task=settings))

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzM1LW9yZGVycy1tYW5hZ2VtZW50LzkwMzI3OS1keW5hbWljYWxseS1hdHRhY2gtZmlsZS10by1lbWFpbD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86583
- Thank you received: 14324
-
-

5 years 1 month ago [\#336125](#336125) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Dynamically attach file to email](/forum/35-orders-management/903279-dynamically-attach-file-to-email#336125 "-- HikaShop version -- : 4.4.3 -- Joomla version -- : 3.10 -- PHP version -- : 7.4  Hi,  I need to dynamically attach a file to the &quot;order administrator notification&quot; email.  I imagine I could simply add something like  to the preload PHP, correct?  I have no trouble setting/getting $filename, but what should &quot;xyz&quot; be?  Thanks for a hint.")*

Hi,

You should be able to do it like that: Code:

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

The following user(s) said Thank You: [lousyfool](/forum/user/28604-lousyfool "View lousyfool's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzM1LW9yZGVycy1tYW5hZ2VtZW50LzkwMzI3OS1keW5hbWljYWxseS1hdHRhY2gtZmlsZS10by1lbWFpbD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[lousyfool](/forum/user/28604-lousyfool "View lousyfool's Profile")**
- [![lousyfool's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar28604.jpg)](/forum/user/28604-lousyfool "View lousyfool's Profile") Topic Author
- [ Offline](/forum/user/28604-lousyfool)

Less More

- Posts: 2143
- Thank you received: 746
-
- [](http://www.inphase.one)
-

5 years 1 month ago [\#336145](#336145) by [lousyfool](/forum/user/28604-lousyfool "View lousyfool's Profile")  Replied by *[lousyfool](/forum/user/28604-lousyfool "View lousyfool's Profile")* on topic *[Dynamically attach file to email](/forum/35-orders-management/903279-dynamically-attach-file-to-email#336145 "-- HikaShop version -- : 4.4.3 -- Joomla version -- : 3.10 -- PHP version -- : 7.4  Hi,  I need to dynamically attach a file to the &quot;order administrator notification&quot; email.  I imagine I could simply add something like  to the preload PHP, correct?  I have no trouble setting/getting $filename, but what should &quot;xyz&quot; be?  Thanks for a hint.")*

Hi Nicolas,

Excellent -- works great! And with this in hand it was easy to attach multiple files, too... ![:)](/media/kunena/emoticons/3.png ":)")

Merci mille fois!

---

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

The following user(s) said Thank You: [nicolas](/forum/user/63-nicolas "View nicolas's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzM1LW9yZGVycy1tYW5hZ2VtZW50LzkwMzI3OS1keW5hbWljYWxseS1hdHRhY2gtZmlsZS10by1lbWFpbD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.048 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
