Symfony – send HTML mail from task with view partial

Do you need send mail from symfony task? No problem!

$mailer = sfContext::getInstance()->getMailer();
sfContext::getInstance()->getConfiguration()->loadHelpers(array(‘Partial’));

$message = $mailer->compose(array(‘admin@test.com’ => ‘Nice mail’),
‘someone@test.com’,
‘Test’);

$message->setBody(get_partial(‘module/mailPartial’), ‘text/html’);
$mailer->send($message);

Have a nice day! ๐Ÿ™‚

Leave a Comment: