How to send mail

Hi,

I want to send some mails from my turris using the same service as the updater (sender: turris@notify.turris.cz). Is this possible or do I have to use some other mail provider?

Thanks!

You can create your own notifications by (ab-)using the tool /usr/bin/create_notification:

# create_notification 
This program serves for creating messages which will be send to the user.
Usage:
         /usr/bin/create_notification -s [restart,error,update,news] 'Czech text of the message' 'English text of the message'

Such notification would then appear on the homepage of Foris and, if you’ve set up e-mail notification, you’ll get those as well.

I wanted to send mail as welll :wink: (as part of script testing WAN connection by pinging some site). But even though I used this tool with or without optional parameters [restart,…] there was always only error message issued, as you could see below:

  • /usr/bin/create_notification -s error “Tue Nov 15 17:30:20 CET 2016 www.upc.cz WAN NONE” “Tue Nov 15 17:30:20 CET 2016 www.upc.cz WAN NONE”
    This program serves for creating messages which will be send to the user.
    Usage:
    /usr/bin/create_notification -s [restart,error,update,news] ‘Czech text of the message’ ‘English text of the message’

Could you please advice?

I am using ssmtp.

echo “Blah blah blah” | ssmtp -s “Subject” nemam@vubec.nic

Work like a charm.

https://wiki.openwrt.org/doc/howto/smtp.client

1 Like

Exactly this command works for me perfectly. Try to double check whether you are properly quoting all spaces in the scripts that calls it.

But in such case, you have to provide your own smart relay for the mail.

What you’ve seen was debug display of part of script (ie “set -x”) Line in question is:

if [ $STATUS != “OK” ]
then NOTE="$DATE $ISP WAN $STATUS"
/usr/bin/create_notification -s error ‘$NOTE’ '$NOTE’
fi

(no difference whether single or double qoute about “$NOTE” variable was used :frowning: unfortunately) What next? I’d like if this tool would work even for me :smile:

It should look like this:

/usr/bin/create_notification -s error "$NOTE" "$NOTE"

In your example, the backslashes are disabling the quotes’ function, which means your message will get splitted by shell into separate arguments. That’s why there’s too many arguments for create_notification, which results in showing the usage help and exitting.

Thanks and sorry - I need to refresh anything I forget as to UNIX/Linux background :frowning:

/usr/bin/create_notification -s [restart,error,update,news] 'Czech text…
Could you please explain meaning of parameters? ie. does any of them invoke some action?
TIA

They differ in colour and heading text in the e-mail:

	local heading_restart="Restart is needed"
	local heading_errors="Error notifications"
	local heading_updates="Update notifications"
	local heading_news="News announcements"

The severity restart has also a side effect of scheduling restart of the device.

Thanks… (Ď)