Package email template

I have made a package with a number of blocks and one of those blocks is a form that -- once completed -- will need to send an email. I'd like to add a custom email template to the package and I cannot find a way to include it in the package installation process.
For the blocks I use installBlockTypeFromPackage. Is there something like 'installEmailTemplateFromPackage'?

View Replies: View Best Answer
47559Tom replied on at Permalink Reply
Furthermore: I assume it's possible to format an email template as HTMl mail. But how do I add an attachment with the Mail Helper class?
dg1 replied on at Permalink Reply
Any ideas on this?

I also have a package I am trying to put together and I am looking for a way to install a mail template from the package. I also can't figure out how to install a php file in models. Right now, I have to manually copy a few files into the appropriate directories, but it would be nice if the package controller could handle them. The docs only seem to address single pages and blocks but not other types of files.
47559Tom replied on at Permalink Best Answer Reply
Well, I kinda gave up on using an email template. Mostly because it seems to be supporting only plain text, and not HTML mail which I prefer for esthetic reasons.

The solution I do use is this:

1. Format the email body with HTML tags and all in one string.
2. Create a Zend_Mail object (I copied some bits and pieces from the mail helper).
3. Put the email string into the HtmlBody of the Zend_Mail object.
4. Add email addresses for to, from, cc, bcc, replyto et cetera, and add attachments.
5. Send the whole thing of.

This makes nicely formatted emails with all the bells and whistles you could wish for.

As for your second issue: a lot of things can be done in the install function of the package controller. Moving files around, adding data to the database, and what not. It's just that only a limited set of functions are available for installing specific much used objects. A mail template could of course be moved to the right place 'by hand'. Convenient? Maybe not. But providing an API function for anything and everything imaginable isn't either.
basicus replied on at Permalink Reply
Thank you! :)
programmieraffe replied on at Permalink Reply
In 5.5 it is possible the following way, I successfully tested it a few minutes ago.

Put mail template in packages/<your_package>/my_template.php.

Loading a mail template from package:
$mh->load("company_new_account_information", "your_package_handle");

For HTML-mails: Use bodyHTML in <your_package_handle>/mail/my_template.php
// html mail content
$bodyHTML = t("<h2>Meine Email</h2>

<p>Username: %s</p>",
// normal text content would be $body

Full documentation here:
No need to set something up in package/controller.php.

( I know the thread is from 2010, but I stumbled about it and saw no better threads in the meantime, so I posted it here for other readers )