Skip to content

Instantly share code, notes, and snippets.

@lucasmezencio
Created June 25, 2012 20:25
Show Gist options
  • Save lucasmezencio/2991003 to your computer and use it in GitHub Desktop.
Save lucasmezencio/2991003 to your computer and use it in GitHub Desktop.
Creating Attachment From View With Zend Framework
<?php
$mail = new Zend_Mail();
$attach_view = new Zend_view();
$attach_view->setScriptPath('/path/to/views/directory/');
$attach_view->name = 'Lucas';
$attach_view->lastName = 'Mezencio';
$attachment = $attach_view->render('view.phtml');
$mail
->setFrom('[email protected]', 'Label From')
->setSubject('Subject')
->addTo('[email protected]');
$at = $mail->createAttachment($attachment);
$at->type = 'mime/type';
$at->disposition = Zend_Mime::DISPOSITION_INLINE;
$at->encoding = Zend_Mime::ENCODING_BASE64;
$at->filename = 'example.ext';
$mail->send();
<html>
<head>
<title>teste</title>
</head>
<body>
Hello <?php echo $this->name; ?> <?php echo $this->lastName; ?>!
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment