I still have a lot of cleanup to do, update the quick-start guide, etc. I expect that unless there are more issues with email, I should have the final version of v3.1 out next weekend. It just takes time to go though and clean up my mess.
When you run the script for the first time, it will download the new python script for sending emails. I need to work on identifying updates should there need to be any.
P.S. I wish Elon Musk would quit sending me emails about selling me a magazine subscription, Iād be fine with some cash in my pocket instead. Okay, it is some jerk posing as Elon Musk, but Iād still like the cash donation
If you have an email problem (yes, still one person for certain has it), please drop me an email or message here on the forums and include the following data: midclt call mail.config | jq
And in your script directory will be a new folder called mrlog, please attach the most current file. Do not post this file in the general forums, it will contain your email address, which as you know, I never share without explicit permission. to day, never shared any.
EDIT: Please remove your password from the mail.config file. If you do not, I will redact it and slightly modify any email address as well for you before sharing the data with @oxyde. I believe in security and privacy.
It still doesnāt like recipients or senders that are .stream addresses.
.stream recipient
File /mnt/Orac/Scripts/mrlog/20250112_085253.txt successfully generated
2 totals file log
0 totals attachment
trying read mail.config
read mail.config successfully
Switching for the right provider
** SMTP Version **
parsing smtp config
parsing html content
body is a file
check for attachements...
establing connection...
KO: (553, b'Invalid domain name')
.net recipient
File /mnt/Orac/Scripts/mrlog/20250112_161526.txt successfully generated
3 totals file log
0 totals attachment
trying read mail.config
read mail.config successfully
Switching for the right provider
** SMTP Version **
parsing smtp config
parsing html content
body is a file
check for attachements...
get hostname
hostname: Orac.
establing connection based on security level set on TN: PLAIN
entered PLAIN path
Neither had me receiving emails. Temporarily have changed to gmail and that works.
The first log seems the output of the previous version of the script (it should have logged more info before give the KO), the second one just stop without grabbing anything else, nor the sent and the except did Joe give to you my email address? Can you share with me some more info in private?
@Vollans donāt know if you still need, but i pushed a new version on GitHub, the v 0.04, use that instead the one i posted above because iām quite sure will fix your issue, and if not, will log more step for a better troubleshooting (the log interrupted too should be fixed now)
First off, Thank you to everyone that got this up and working again. I have been using this script for quite some time.
When I run the update it creates new files (config.txt and multi_report.sh) that I have to rename to get the script working again. Is this the intended behavior or am I missing something?
Seems the beta pattern, you should move back to the stable branch.
In case just hook the latest files directly from GitHub, and rerun the script. Give a look into guide before, there are some little changes to make
I upgraded from 23.10.x to 24.10.2 today, and ran into the same sendmail issue.
I only came across this post after I had already fixed it on my end, so sharing for posterity (though realize not everyone will be comfortable with doing the same):
install-dev-tools # amongst other things, this will enable dpkg
dpkg-reconfigure exim4-config # change mail server type to 'Internet site', leave everything else as-is
Your existing sendmail-based scripts will look something like
sendmail -t -oi < "${logfile}"
Change that to
exim "${email}" < "${logfile}"
This āfixā will only last until the next system upgrade, but that does not bother me. āinstall-dev-toolsā is the first thing I do after an upgrade anyway.
Another solution that worked for me, without enabling developer mode, and without using exim, is simply to go grab the Python script that TrueNAS shipped as sendmail in older releases.
You donāt need it to be setuid for admin or root users to be able to use it, which is all I needed. Itās not clear to me why they felt the need to remove it entirely.
@oxyde Iām trying to use your script to send an email at shutdown.
Specifically I want the OS to generate an email alert when a shutdown/reboot is requested. What Iām finding is the network is down before the script completes. By network I mean the active wireguard tunnel and networking service.
It would seem the script (or commandline) needs to fire before any of these services are terminated. TN (24.10.2) is lightning fast to shut things down.
Any thoughts or suggestions how to implement this? Thanks
Honestly, i donāt have an answer for this.
Donāt think i can perform anything in my script to compensate the bad timing in this use case, and i donāt have direct experience with shutdown scripts at all (btw from GUI donāt seems there are many fancy customization option).
Anyway the use case Is interesting, i will try It too, just to see if the result will be the same
Some more context. I want to deploy a TN box at a remote location (neighborās house). While I will generally be able to access it, it would be nice to know if itās there are unscheduled reboots or shut downs.
Generating an email works just fine on startup - with a 10-20s sleep delay preceding sending of the email. I think shutdown/reboot not due to power failure is just as important.
Here i am after some tests.
Iām using a dumb VM with Fangtooth, last not-already-released version of my script, connected with an outlook account (the slower to send email, it takes at least 2-3 times more than other provider)⦠and is working.
I receive an email nor shutting down from gui and terminal.
I have wrapped the actions in a script instead of using a command (not working for me), really simple (after have checked passwordless sudo):
#!/bin/bash
sudo su <<EOF
cd /mnt/Test/Script
python3 multireport_sendemail.py --subject "VM poweroff" --to_address "***@gmail.com" --mail_body_html "<h1>TEST</h1><p>shutdown script</p>"
EOF
I understand that my setup is minimal, but i neither needed to put higher timeouts or āsleepā⦠can you try as i do with this setup?
Thatās about what my script looks like, mainly just calling the sendmail.py with appropriate parameters.
I tried calling it via the init/shutdown functions, and as a service. The former doesnāt work at all, middleware is downed before the python script finishes. Same with running it as a service.
As a service works when testing on local lan, but not remotely. My remote connection is established by connecting the test truenas box via ethernet to another router, then wireguard to my pfsense (as a peer). That other router gets internet from an ethernet tethered phone using mobile data. So from one extreme to the other. Pings between the two end points can be as high as 300ms (mobile data service sucks around here).
I think the goal to making this work is to figure out how to ensure the sendmail.py completes fully before TN shuts down all its services.
For the service I had
[Unit]
Description=Shutdown Email Notification Process
#DefaultDependencies=no
#Before=shutdown.target
#After=middlewared.service network.target
#Requires=network.target
Before=shutdown.target reboot.target
#Requires=middlewared.service wg-quick@wg0.service
Requires=wg-quick@wg0.service
# This works because it is installed in the target and will be
# executed before the target state is entered
# Also consider kexec.target
[Service]
Type=oneshot
RemainAfterExit=true
ExecStart=/bin/true
ExecStop=/root/util/shutdownemail.sh
TimeoutSec=30
[Install]
WantedBy=multi-user.target
#WantedBy=halt.target reboot.target shutdown.target
For the script
#!/bin/sh
uptime=$(awk '{print $1}' /proc/uptime)
uptime=$(echo $uptime | awk '{ printf "%d\n",$1 }' )
if [ "$uptime" -lt "30" ] ;
then
exit
else
/usr/bin/python3 /root/sendmail.py --subject "Remote Nas Shutdown on $(date)" --to_address user@domain.com --mail_body_html "Shutdown or reboot occurred on $(date)"
fi