0

I am trying to use Swift_Validate::email($email) and I get a php error: PHP Fatal error: Class 'Swift_Validate' not found.

I have the latest version of swiftmailer. Is there some preference settings I need to do?

I have tried including the Validate.php file, but then I get the error: PHP Fatal error: Class 'Swift_DependencyContainer' not found.

I include DependencyContainer.php and I get the error PHP Fatal error: Class 'Swift_DependencyException' not found.

I include DependencyException.php and I get the error: Class 'Swift_SwiftException' not found.

I include SwiftException.php and I still get the same error.

I think I must not have the preferences set up correctly. I am calling: "require_once($dir.'/swift/swift_required.php');"

The code I am using for the validation is: if (!Swift_Validate::email($email)) { $error = true; }

Any help would be greatly appreciated. Using latest Apache and PHP.

MonteVista
  • 15
  • 5

1 Answers1

0

Try require_once dirname( __FILE__) . '/lib/swift_required.php'; to use the built-in autoloader, where lib is subfolder of folder where is the current file ( for default directory structure of the library )

Danijel
  • 12,408
  • 5
  • 38
  • 54
  • Thanks! for some reason it didn't like my $dir = dirname(__FILE__); I placed the include as you wrote it at the top of the PHP and it worked. Thanks to you and amenadiel. Much appreciated. – MonteVista Jun 23 '14 at 18:01