I tried implementing the new version, and found it was incompatible.

I also needed STARTTLS authentication which is not in the swiftlibrary
so I had to convert to the PHPMailer library.  It was pretty easy. I
only needed to:

1. overwrite two sf Apply methods by creating my own modules/sfApply/
actions.class.php.
2. put the phpmailer library in my /lib folder
3. create a Mailer class which extends the PHPMailer class and
configures my default smtp authentication information.

Unfortunately this means you may need to manually update those actions
in the future (when updates are made to sfApply).

-pat

<?php

/**
 * sfApply actions.
 *
 * Overwritten to use the phpMailer instead of swiftmailer, because
swiftmailer 3.3.3 and 4.01 as of this writing don't support TLS
 *
 * @package    5seven5
 * @subpackage sfApply
 * @author     Patrick Cummins
 * @version    SVN: $Id: actions.class.php 2692 2006-11-15 21:03:55Z
fabien $
 *
 *
 */

// Necessary due to a bug in the Symfony autoloader
require_once dirname(__FILE__).'../../../../../../plugins/
sfDoctrineApplyPlugin/modules/sfApply/lib/
BasesfApplyActions.class.php';

class sfApplyActions extends BasesfApplyActions
{

       /**
        * Override the default apply action (to use PHPMailer because
it
supports STARTTLS and swiftmailer does not)
        *
        * @param sfRequest $request
        * @return unknown
        */
       public function executeApply(sfRequest $request)
       {
               $this->form = $this->newForm('sfApplyApplyForm');
               if($request->isMethod('post'))
               {
                       $this->form->bind($request->getParameter
('sfApplyApply'));
                       if($this->form->isValid())
                       {
                               $guid = "n" . self::createGuid();
                               $this->form->setValidate($guid);
                               $this->form->save();
                               try
                               {

                                       $mailer = new Mailer();
                                       $mailer->Subject =
sfConfig::get
('app_sfApplyPlugin_apply_subject', "Please verify your account on " .
$request->getHost());

                                       // Render message parts
                                       $profile = $this->form-
>getObject();
                                       $mailContext = array('name' =>
$profile->getFullname(),
'validate' => $profile->getValidate());
                                       $mailer->AltBody = $this-
>getPartial('sfApply/
sendValidateNewText', $mailContext);
                                       $mailer->MsgHTML($this-
>getPartial('sfApply/sendValidateNew',
$mailContext));
                                       $mailer->AddAddress($profile-
>getEmail(),$profile->getFullname
());

                                       $mailer->Send();

                                       return 'After';

                               }
                               catch(Exception $e)
                               {
                                       $mailer->disconnect();
                                       $profile = $this->form-
>getObject();
                                       $user = $profile->getUser();
                                       $user->delete();
                                       // You could re-throw $e here
if you want to
                                       // make it available for
debugging purposes
                                       return 'MailerError';
                               }
                       }
               }
       }

       /**
        * Override the reset request (to use PHPMailer because it
supports
STARTTLS and swiftmailer does not)
        *
        * @param unknown_type $user
        * @return unknown
        */
       public function resetRequestBody($user)
       {
               $this->forward404Unless($user);

               $profile = $user->getProfile();
               $profile->setValidate('r' . self::createGuid());
               $profile->save();

               $mailer = new Mailer();
               $mailer->Subject = sfConfig::get
('app_sfApplyPlugin_reset_subject',
sfContext::getInstance()->getI18N()->__("Please verify your password
reset request on %1%", array('%1%' => $this->getRequest()->getHost
())));
               $mailContext = array('name' => $profile->getFullname(),
'validate'
=> $profile->getValidate());
               $mailer->AltBody = $this->getPartial('sfApply/
sendValidateResetText', $mailContext);
               $mailer->MsgHTML($this->getPartial('sfApply/
sendValidateReset',
$mailContext));
               $mailer->AddAddress($profile->getEmail(),$profile-
>getFullname());
               $mailer->Send();

               return 'After';
       }

}

On Jul 5, 2:54 pm, Alexey <[email protected]> wrote:
> Because there is new version of Swift! :)
> and the sfDoctrineApply was written to work with Swift 3.3.3 (?). in
> new version they changed classes and it seems there are some problems
> with autoloading swift library.
>
> On 4 июл, 22:23, Gregoire Laporte <[email protected]> wrote:
>
> > why?
--~--~---------~--~----~------------~-------~--~----~
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