0

I installed Kohan Email module from http://github.com/banks/kohana-email to my Kohana Frameword and when I'm trying to register on my website I get following issue:

Fatal error: Cannot redeclare class Swift in 
C:\xampp\htdocs\biblioteka\modules\email\vendor\swift\classes\Swift.php on line 29

I used following codes to send an email:

Email::send('example1@gmail.com', 'example2@gmail.com', 'tittle', 'content');

and

require Kohana::find_file('vendor', 'swift/swift_required', 'php');
$transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465);
$mailer = Swift_Mailer::newInstance($transport);
$message = Swift_Message::newInstance('Email')
        ->setFrom(array('example1@gmail.com' => 'From'))
        ->setTo(array('example2@gmail.com'))
        ->setBody('An email');
$result = $mailer->send($message);

There's the same problem for boths of codes.

MeIr
  • 7,236
  • 6
  • 47
  • 80

1 Answers1

0

You should not be directly including any swift files from the vendor directory, or instantiating any swift classes.

As long as you have the following line in your bootstrap.php file, the necessary files will be included from the vendor directory by the email module.

Kohana::modules(array(
    // Other modules here...
    'email'      => MODPATH.'email',         // Email
));

The reason you're getting an error telling you you've already declared swift, is because you have (via the email module).

You then just send emails using your first example (Email class only):

Email::send('example1@gmail.com', 'example2@gmail.com', 'tittle', 'content');
chrisboustead
  • 1,573
  • 12
  • 17