Reputation: 2539
I want to set up a user login process on top of sfGuardDoctrine, which sets the password to a random one. This is happening when the user is created or when his password is reset.
I figure I should centralise this routine in the sfGuardUser model class? What I can't figure out is how to get the Swiftmailer instance from there. All documentation seems to call it from within an action.
Upvotes: 0
Views: 1000
Reputation: 823
You need to get the context to get access to the mailer object. This is a compose and send example that should work in your model class.
$sent = sfContext::getInstance()->getMailer()->composeAndSend(
"sender_email",
"recipient_email",
"subject",
"body"
);
Upvotes: 3