Could not find SwiftMailer

My EmonCMS is self-hosted in EmonPi running on pre-built EmonSD image (emonSD-03May16).

EmonCMS Version = low-write 9.7.7 | 2016.10.29 (Perform note 1, when error message below encounted)
Operating System = Linux 4.1.19-v7+
No change to the code.
note 1 : Selected “Update Now” in Update emonPi in admin/view of EmonCMS.


After I create processes (i.e. condition) for sending email in Inputs and try to simulate the event, an error below appeared in Logger of EmonCMS ( /var/log/emoncms.log) :

|ERROR|email.php|check() Could not find SwiftMailer, email functions are ignored

I try to update latest EmonCMS (note 1) but the error still exist.

Is there any update to resolve the above error?


Do you have Swiftmailer installed?

pear channel-discover
pear install swift/swift

I had the same issue, even with it installed and found editing emoncms/Lib/email.php sorted it for me.

I found the swift_required.php file was not in the Swift folder but on the same level as it

[email protected]: $ ls -la /usr/share/php/{Swift*.*,swift*.*,Swift/Swift*.*}
-rw-r--r-- 1 root root  735 Jun 13 18:20 /usr/share/php/swift_init.php
-rw-r--r-- 1 root root 2110 Jun 13 18:20 /usr/share/php/Swift.php
-rw-r--r-- 1 root root  693 Jun 13 18:20 /usr/share/php/swift_required.php
-rw-r--r-- 1 root root  536 Jun 13 18:20 /usr/share/php/Swift/SwiftException.php

so by changing

$this->have_swift = @include_once ("Swift/swift_required.php");


$this->have_swift = @include_once ("swift_required.php");

seemed to do the job.

However I cannot say if that is a “good fix” or not, I’m not good with PHP and I find that piece of code a bit confusing as the following couple of lines seem to be a fall back for when “pear” swift isn’t installed, it appears to want to resort to using emoncms/Lib/swiftmailer/swift_required.php which doesn’t exist and presumably therefore doesn’t work.

Hi, I was having the same problem and wanted a solution that doesn’t rely in Pear as access to share hosts can be limited. Then, as Paul says, the fallback solution doesn’t work as Swift Mailer is not in the Lib directory.

To make it work I have added Swift Mailer to the Lib, also I had to tweak email.php as the swiftmailer’s newInstance() methods don’t work anymore.

Find the solution in this emoncms fork and branch. You have to:

  • replace email.php in Lib
  • copy the mail directory into Lib