Skompilovať latte do html a priložiť k emailu
- sepo
- Člen | 69
Ahoj
ako skompilovať latte a priložiť ako súbor (html) k emailu
teraz používam niečo takéto :
$exportFile = TEMP_DIR.'/ORDERS_NO_VALID_ADDRESSES.html';
$file = fopen($exportFile, "w");
fwrite($file, '<html><head>..')
foreach ($records as $value) {
fwrite($file, '<tr><td>....');
}
fwrite($file, '</table></body></html>');
fclose($file);
$message = new Message;
$message->setFrom('xx@yy.com')
->addTo('xxx@com')
->setSubject('NOTICE: ORDERS_NO_VALID_ADDRESSES')
->addAttachment($exportFile);
- sepo
- Člen | 69
tak som sa dopracoval k tomu to
$latte = new Engine;
$template = new Template($latte);
$template->setFile(__DIR__.'/ORDERS.latte');
$template->records = $records;
$message = new Message;
$message->setFrom('xx@yy.com')
->addTo('xxx@com')
->setSubject('NOTICE: ORDERS_NO_VALID_ADDRESSES')
->setHtmlBody('ORDERS');
$message->addPart()
->setContentType('text/html')
->setEncoding(Message::ENCODING_BASE64)
->setBody($template)
->setHeader('Content-Disposition','attachment; filename="ORDERS.html"');