Last active
October 12, 2020 16:48
-
-
Save damiann/6287556 to your computer and use it in GitHub Desktop.
Send Magento template email with attachment.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
// using model magento\app\code\core\Mage\Core\Model\Email\Template.php | |
public function send_error_email($error = NULL) { | |
$mailTemplate = Mage::getModel('core/email_template'); | |
$mailTemplate->setSenderName('Insert Sender Name'); // use general Mage::getStoreConfig('trans_email/ident_general/name'); | |
$mailTemplate->setSenderEmail('[email protected]'); // use general Mage::getStoreConfig('trans_email/ident_general/email') | |
$mailTemplate->setTemplateSubject('Insert Subject Title'); | |
$mailTemplate->setTemplateText('Insert Body Text'); | |
// add attachment | |
$mailTemplate->getMail()->createAttachment( | |
file_get_contents(Mage::getBaseDir('base') . '/var/log/file.log'), | |
Zend_Mime::TYPE_OCTETSTREAM, | |
Zend_Mime::DISPOSITION_ATTACHMENT, | |
Zend_Mime::ENCODING_BASE64, | |
'file.log' | |
); | |
$mailTemplate->send($to_email_arr, $to_name_arr); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment