Custom email for notifications sends out mails without From:

I have tested the use of sending mails for notification. However, when using my own mail server (I run it myself) I have set a number of strict procedures to reduce the number of spam messages being received.

I noticed that the mails the Omnia sends aren’t valid, because they lack a proper From:

554 5.7.1 <DATA>: Data command rejected: Sender access denied; from=<> to=<my.email@domain> proto=ESMTP helo=<localhost>

Notice that the from is empty, even if set in Foris. This triggers the sending policy rejection in my Postfix configuration (because of invalid sender).

Take a look in

/etc/config/user_notify

And see if things are configured correctly in that file.

Thanks, I’ll check once I get home.

Here is btw my config and it works. I used a gmail account for this. Maybe other users find settings useful if they want to setup a gmailaddress so i have kept and gave certain info regarding the settings.

config smtp 'smtp'
        option sender_name 'turris'
        option enable '1'
        option use_turris_smtp '0'
        option server 'smtp.gmail.com'
        option port '587'
        option username '<USERNAME-(SENDS-FROM-EMAIL-ADDRESS>)'
        option password '<PASSWORD-(SENDS-FROM-EMAIL-ADDRESS>)'
        option security 'starttls'
        option from 'SENDS-FROM-EMAIL-ADDRESS>'
        list to '<SENDS-TO-EMAIL-ADDRESS>'

config notifications 'notifications'
        option severity '3'
        option news '1'

config reboot 'reboot'
        option delay '3'
        option time '03:30'

Looks like you’ve found another bug that has been there since 2014 unnotified. Congrats! :wink:

Fix is quite simple, already submitted.

@Ondrej_Caletka

Could this missing Sender bug be a reason why I have had some strange problems as well even though I reeived “Too many recipients…”

Failed to send: msmtp: recipient address xxxxx@xxxxx.xx not accepted by the server
msmtp: server message: 452 Too many recipients received from the sender

[SOLVED] Notifications settings - Errors

Possibly yes, feel free to try the fix.

Being an old Mac-guy making slow moves into the linux area, how do I incorporate this change into my Omnia? :slight_smile:

Hi @Big_boss, are you using “/usr/bin/create_notification” or another mailer? If another, could you please share more details, as to what modules are needed, how to config it etc. or point me to proper guide/documentation? TIA!

The only thing i did was…in Foris

–><Omnia Ip mine (192.168.1.1)> → went to “maintenance” and there i configured it as that. See the print-screen…

Do save first, before “send testing message”. btw, these are for when a update is given by Omnia-team.

I am planning to look for another way or so…to analyze for example certain amount of “login-failure” or so and that it sends me a notification by email…but i have to make a script or so for that. That is a “future” idea.

@Ondrej_Caletka Applied your fix, all working, thanks!

How can apply it too?
In /etc/config/user_notify or some where else?

You have to edit the file named /usr/bin/notifier. Replace both occurrences of $from with $mail_from.

2 Likes

Thanks a lot.

All solved!
Testing message was sent, please check your inbox.

It would be nice if this feature was built into future releases of Turris OS.

I also run my own mail server, Postfix, and it’s configured to use postscreen to fight spam. This repels the client if the HELO/EHLO hostname is invalid (e.g. localhost) before SMTP authentication could take place. Unfortunately notifier/msmtp sends mail this way.

Incorporating this diff into notifier makes it work properly and automatically:

root@turris:~# diff -u notifier.old /usr/bin/notifier
--- notifier.old	2017-04-22 21:38:44.245259000 +0200
+++ /usr/bin/notifier	2017-04-22 21:38:14.855259000 +0200
@@ -64,10 +64,12 @@
 	local server=`uci -q get user_notify.smtp.server`
 	local port=`uci -q get user_notify.smtp.port`
 	local security=`uci -q get user_notify.smtp.security`
+	local helodomain=`uci -q get user_notify.smtp.from | cut -d '@' -f2`
 
 	echo "from $mail_from" >> "$msmtp_cfg_file"
 	echo "host $server" >> "$msmtp_cfg_file"
 	echo "port $port" >> "$msmtp_cfg_file"
+	echo "domain $helodomain" >> "$msmtp_cfg_file"
 
 	if [ "$security" = "ssl" ]; then
 		echo "tls on" >> "$msmtp_cfg_file"
root@turris:~#
1 Like

You should make a pull request out of it.

However, the way you generate HELO hostname straight from the originating e-mail address is not a good idea as originiating e-mail address domain name is usually not the host name of the router. Much better would be to put there an IP address, as recommended by RFC 5321:

The SMTP client MUST, if possible, ensure that the domain parameter to the EHLO command is a primary host name as specified for this command in Section 2.3.5. If this is not possible (e.g., when the client’s address is dynamically assigned and the client does not have an obvious name), an address literal SHOULD be substituted for the domain name.

Thanks Ondrej, I didn’t know about the RFC and thought that either a hostname or a mail domain will do.

Regarding the pull request: I don’t wish to register on Github, can I do this without that?