Community
OpenEnergyMonitor

OpenEnergyMonitor Community

Raising event to send as email -> Could not find SwiftMailer, email functions are ignored

Hi,

I’m wanting to send an email when the battery in the emonTH is flat.
I’ve got the rules setup But I get

2021-06-23 11:01:40.959|ERROR|email.php|check() Could not find SwiftMailer, email functions are ignored.
2021-06-23 11:01:40.959|ERROR|eventp_processlist.php|Email send returned error. message=‘Could not find SwiftMailer, email not sent.’

I’ve tried to install swiftmailer with pear But i get

pear channel-discover pear.swiftmailer.org
Discovering channel pear.swiftmailer.org over http:// failed with message: channel-add: Cannot open “http://pear.swiftmailer.org/channel.xml” (File https://swiftmailer.symfony.com:443/channel.xml not valid (received: HTTP/1.1 404 Not Found
))
Trying to discover channel pear.swiftmailer.org over https:// instead
Discovery of channel “pear.swiftmailer.org” failed (channel-add: Cannot open “https://pear.swiftmailer.org/channel.xml” (Connection to `ssl://pear.swiftmailer.org:443’ failed: Connection refused))

Any thoughts?

Thanks

Hello @david emoncms currently uses an older version of swift mailer, you should be able to install using the command (assuming that you have an emonPi/base system):

git -C /opt/emoncms/modules clone -b 'v5.4.8' --single-branch https://github.com/swiftmailer/swiftmailer.git

Ace!!!

that fixed it - I’m getting my test email now

Thanks!

@david, lucky for you :slight_smile: . I still have trouble having a working ‘send as email’ :frowning: . Maybe you can see what is wrong with my setup?

Hi @m2ts sure - I’ll do what I can.
Whats the error message that you are seeing in the logs?

@david, I guess you mean in /var/log/emoncms/emoncms.log?

2021-06-24 06:41:40.683|ERROR|emoncms_mqtt.php|ErrorException: Trying to access array offset on value of type null in /var/www/emoncms/Modules/eventp/eventp_processlist.php:110
Stack trace:
#0 /var/www/emoncms/Modules/eventp/eventp_processlist.php(110): exceptions_error_handler()
#1 /var/www/emoncms/Modules/process/process_model.php(71): Eventp_ProcessList->sendEmail()
#2 /var/www/emoncms/Modules/process/process_model.php(122): Process->__call()
#3 /var/www/emoncms/scripts/services/emoncms_mqtt/emoncms_mqtt.php(397): Process->input()
#4 [internal function]: message()
#5 /var/www/emoncms/scripts/services/emoncms_mqtt/emoncms_mqtt.php(142): Mosquitto\Client->loop()
#6 {main}

Any ideas what could be wrong?

I also think the time is 2 hours off. I think the log should be ‘2021-06-24 08:41’ instead of ‘06:41’. The timezone in my emoncms-account is 'GMT +02:00"

Line 110 suggests an issue with either sourceid or sourcetype options emoncms/eventp_processlist.php at master · emoncms/emoncms · GitHub, What did you enter in the text field when you created the event?

I used the example body text At {time} your {type} from {node} with key {key} named {name} had value {value}. I now changed it to A test e-mail. I’ll keep you updated.

Unfortunately to no success :-(. The strange things I see:

  1. I don’t get get an e-mail, because error Trying to access array offset on value of type null remains.
  2. The time in the log is 2 hours off.
  3. As long as I exceed the value of the quarter peak, I’ll get an e-mail every 10 seconds. But first I need to fix the sending of the e-mail itself…

I tried to know if there is an issue with either sourceid or sourcetype option, by adding the following code, but newfile.txt remains empty. The strange thing is that the error still refers to eventp_processlist.php:110 which is now the line $myfile = .... So it seems emoncms is working with “the old code”.

        $tag = array("{id}","{type}","{time}","{value}");
        $myfile = fopen("/var/www/emoncms/Modules/eventp/newfile.txt", "w") or die("Unable to open file!");
        fwrite($myfile, "sourceid" . $options['sourceid'] . "\n");
        fwrite($myfile, "sourcetype" . $options['sourcetype'] . "\n");
        fwrite($myfile, "time" . $timeformated . "\n");
        fwrite($myfile, "value" . $value . "\n");
        fclose($myfile);
        $replace = array($options['sourceid'],$options['sourcetype'],$timeformated, $value);

I couldn’t fix the e-mail problem in emoncms, so I went for another solution with Node-Red that seems to work. See the topic “Calculate quarter-hour peak in kW”.