Need help with custom email

Hello,

Im new to oxid and need to add email functionality to my module.

The module basically gets some stats from database and sends them in a report to a staff member’s email set in module settings through admin panel.
I have everything set up apart from the template and email.
Would love some clarification from those experienced in oxid.

My questions are:

[ul]
[li]Is this how I get the mailer object?
[/li]

$this->mailer = oxNew('oxemail');

[li]How do I get the smarty object?
[/li]

$smarty = ? 

[li]Is this how I attach a template to this email?
[/li]

public function getBody(){
    if (true === $plain) {
        $body = $smarty->fetch($this->templateDir . '/plain/report_plain.tpl');
    } else {
        $body = $smarty->fetch($this->templateDir . '/html/report.tpl');
    }
return $body;
}
(...)
 $this->mailer->setBody($this->getBody)

[li]How do I pass my data to the template?
[/li]Smth like that?

$this->mailer->setViewData(smarty_var_name', $varData);

Or?

$smarty->assign('smarty_var_name', $varData);

[li]How do I access them in the template?
[/li][/ul]

Thank you,
Greg

Maybe this helps: http://www.foxido.de/1294-2

[QUOTE=foxido.de;184112]Maybe this helps: http://www.foxido.de/1294-2[/QUOTE]

Thank you for the reply.

In the end I made it work with a class extending oxemail and adding a method:

public function sendMyCustomRaportEmail()

Inside everything is pretty much the same as in the link. Object instantiations are different cause from inheritance I have access to:


$this->getConfig();
$this->_getSmarty();

Your example would work in any class I make right? Without a need to extend any existing class.

Greg

[QUOTE=gdabrowski;184114]
Your example would work in any class I make right? Without a need to extend any existing class.

Greg[/QUOTE]

Yes, you can use it as an extension or as an independent class and, of course, you have to paste a method arround.