Hi I am working in kohana 3.3.1 . Now I am stuck with an error while i am trying to send a plain text email. The exact error is given below
Fatal error: main() [function.require]: Failed opening required '' (include_path='.:/usr/local/altphp/lib/php:/home/gettrsm3/public_html/web/application/../Utilities:/home/gettrsm3/public_html/web/application/../Utilities/PHPUnit') in /home/gettrsm3/public_html/web/modules/Email/classes/Kohana/Email.php on line 449
Email.php Code(line 448-450)
// Load Swiftmailer
require Kohana::find_file('vendor/swiftmailer', 'lib/swift_required');
function swiftmailer_configurator() {...}
But under swiftmailer directory there is lib/swift_required.php file. anyone has any idea?
Kohana::find_file
is specifically designed to look for files under the Kohana "Cascading Filesystem" structure. In general, this applies to files that are part of your Kohana application itself. It should not be used for a vendor
directory where you always already know exactly what the path to the file will be.
Instead, you should do this:
require APPPATH . 'vendor/swiftmailer/lib/swift_required.php';
Or, if the vendor
stuff is in a module:
require MODPATH . 'MODULE_NAME/vendor/swiftmailer/lib/swift_required.php';
To make the second option here a little more flexible, you can define a new constant in your module's init.php
like this:
define('MODPATH_EMAIL', realpath(dirname(__FILE__)).DIRECTORY_SEPARATOR);
Then you can use this line:
require MODPATH_EMAIL . 'vendor/swiftmailer/lib/swift_required.php';
However, the last (and best alternative) is to use autoloading. If you have installed Swiftmailer in your vendor
directory using Composer, then you can just do this:
require 'vendor/autoload.php'; // Prefix this with anything else as necessary.