Email sender

I’m trying to use the email sender in a rule to send an email when a switch opens. I have everything setup and working in “stand-alone” mode. I can use the Send Email, Send Notification and Simple Email. When I try to use the email sender to send an email as the result of a rule I can not use the Simple Email feature.

Is there a way to limit the email sender to just use the Simple Email feature?

There is a good walkthrough for using the email sender as a rule output in the README here: https://github.com/mozilla-iot/email-sender-adapter

Thank you for the quick response. That tutorial was excellent, that is what I had used to set up the whole email sender.

Let me try to explain what I want to do. I want to send an email to a non-gmail account.

The tutorial says to use a gmail account so I signed up for a gmail email. I set up 2 factor authentication and applied for a APP password. I entered everything into the configuration. When I go to the email thing I can use all 3 email things. This is what happens when I use each:

Send Email - An email is sent to my non gmail account with the subject and body that I entered <— These is the action I want
Send Notification - An email is sent to my gmail account with subject “Notification from WebThings Gateway” and no body
Send Simple email - An email is sent to my gmail account with the subject that I entered and no body

That works as expected.

Then I tried to set up a simple rule. I dragged the clock to the input and set the time to 12:00 PM. At this point there are only 2 email sender things on the bottom of the rule page to pick from. One is “Email Sender Notification” and the other is “Email Sender”. I dragged both of these to the output area. This is what happened at 12:00PM:

Two emails were sent to my gmail account.
one email with subject “Notification from WebThings Gateway” and no body
one email with a subject of (NOTICE)+subject that I entered and the body I entered

Is there a way to have the output of the rule send an email like the “Send Email” to a non-gmail email address?

First off, you can use the email sender with any SMTP service you want, it doesn’t have to be gmail.

To answer your question, though, no, you cannot use that action as a rule output. The rules engine doesn’t currently have support for using complex actions (e.g. actions that take an input) as a rule output. This is why I suggested using the “email sender notification” block for the rule output.

Thank you that is very helpful. I have 2 comments.

First I tried to set up for my preferred email.

I went in and changed the configuration to use the settings for RoadRunner (RR). This is how RR says to set up mail from a client to the RR server: “The settings for TWC are (outgoing server): mail.twc.com on port 587, Connection security = none, authentication = password, transmitted insecurely, User name = full email address.”

I noticed this in the log when I did a test email using the newly entered RR settings:

2020-07-20 13:50:58.057 INFO : email-sender-adapter: { [Error: 1995545040:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:…/deps/openssl/openssl/ssl/record/ssl3_record.c:332:

I took a look at email-sender-adapter.js and it seems to have secure transmission hardcoded. I’m not a java programmer (C is my native language) so I may be wrong. Does the email sender only do secure transport?

Second, you said "The rules engine doesn’t currently have support for using complex actions (e.g. actions that take an input) as a rule output. " The Email Sender Notification thing has 3 inputs (Title, Message, Level) that have to be entered when the thing is added as an output. Am I understanding “actions that take an input” correctly when I refer to the 3 inputs to the Email Sender Notification?

Ah, yes, it only does secure SMTP by default.

As for the rules, the “Notification” is a special rule type that doesn’t directly use an “Action”.

Is there a way to make a change to my installation to email-sender-adapter.js to switch to non secure transport?

I’ve just released v0.4.0 of the add-on. There are new TLS options which can be configured.

Thank you very much. I removed the old email sender thing and installed the new version. I see the changes you made to the configuration screen. After applying the new configs everything seems to be working for the non-secure transmission case. Now I can get rid of that gmail account.

Thanks, I really like this whole project and will continue to use and support the effort.