Hi lukas,
try this. function

public static function sendEmail($infos,$emailTemplate){
        $myContext = sfContext::getInstance();
        $myUser = sfContext::getInstance()->getUser();

        foreach ($infos as $info){
            $myUser->setAttribute($info[0], $info[1], 'symfony/flash');
        }

sfContext::getInstance()->getController()->getPresentationFor('mail',
$emailTemplate, 'sfMail');

    }

i coded it to send emails from batch, bear in mind that $infos is an array
of variables that will be converted into flash variables and will have to be
catched in the action of the email action. For example, if you want to send
"hello $username!"

you will use:

classYouPutStaticmethod::sendEmail(array("username"=>$user()->getUsername(),
"email"=>$user->getEmail()),"templateEmailSayingHello");


hope it helps...
regards





On 8/24/07, Lukas Kahwe Smith <[EMAIL PROTECTED]> wrote:
>
>
> Lukas Kahwe Smith wrote:
> > Hi,
> >
> > I need to load a template inside a batch script. In one case I need to
> > send an email and in one case I need to add some data to the database.
> >
> > I guess for sending an email there is the sendEmail() method on the
> > controller. I guess when I am not sending an email I need to use
> > getAction()?
> >
> > I presume in both cases I need to set attributes on the request object
> > in order to be able to pass in parameters?
> >
> > sfContext::getInstance()->getRequest()->setAttribute('user', $user);
> >
> > Is there any advice/tipps to take into account here?
>
> My frustration continues. After having figured out that I have to
> manually create the instance of sfI18N if I want to use the translation
> system, I now discovered that getPresentationFor() insists on building a
> web controller. Setting is_internal: on also prevented me from loading
> the module inside my batch script.
>
> So how am I supposed to load a template inside a batch script? Would be
> nice to figure this one out. Until then I guess I will implement things
> with using classic includes instead. Narf!
>
> regards,
> Lukas
>
> >
>


-- 
        - Oriol Mercadé Figueras

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to