Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Phalcon Loader PHPMailer


so im using the registerDirs option.

My self created classes get loaded well and work. But once i throw in the PHPMailer folder and try to create a new one i get a 500 error.


class IndexController extends ControllerBase
    public function indexAction()
        $mail = new PHPMailer();

Has anyone an idea what im doing wrong here?

edited Oct '15

hmm, sorry if I am being stupid, can you try

$mail = new \PHPMailer();

and also do you use composer for the instaltion ?

edited Oct '15

When using Phalcon Loader, class names must match filenames. You could use composer, or require_once "PATH_TO_PHPMAILER/PHPMailerAutoload.php"; where you register Phalcon Loader.

edited Oct '15

Thanks for the fast answers.

$mail = new \PHPMailer();

had no effect.

I tried require_once "../library/PHPMailer/PHPMailerAutoload.php"; before and after initializing the loader. The require_once itself causes a 500.

What do you mean by using composer? I thought composer is just a packet manager.

I guess i have to get the damn error reporting to work. Apache is loading a hundred php.inis >.>


Error reporting ftw!

require_once does the job for now. Thanks Lajos.

  1. I think its better to use Swift Mailer.
  2. Create a service and in it require_once library.
  3. If you sending a lot of mails(for exmaple in foreach) - use a queue and cron task.