Package email template
Permalink
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'?
For the blocks I use installBlockTypeFromPackage. Is there something like 'installEmailTemplateFromPackage'?
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?
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.
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.
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.
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.
Thank you! :)
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:
For HTML-mails: Use bodyHTML in <your_package_handle>/mail/my_template.php
[code]
// html mail content
$bodyHTML = t("<h2>Meine Email</h2>
<p>Username: %s</p>",
$username);
// normal text content would be $body
[code]
Full documentation here:
http://www.concrete5.org/documentation/developers/helpers/mail...
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 )
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
[code]
// html mail content
$bodyHTML = t("<h2>Meine Email</h2>
<p>Username: %s</p>",
$username);
// normal text content would be $body
[code]
Full documentation here:
http://www.concrete5.org/documentation/developers/helpers/mail...
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 )