I am trying to get motion to send an email using mailx in a script run when a motion event is detected.
I am using the followin config files:
mail.rc:
$this->bbcode_second_pass_code('', 'set sendmail="/usr/bin/msmtp"
set message-sendmail-extra-arguments="-a gmail"
')
msmtprc:
$this->bbcode_second_pass_code('', '#Gmail account
defaults
logfile ~/msmtp.log
account gmail
auth on
host smtp.gmail.com
from my_account_here@gmail.com
auth on
tls on
tls_trust_file /usr/share/ca-certificates/mozilla/Equifax_Secure_CA.crt
user my_account_here@gmail.com
password *******
port 587
account default : gmail
')
I have a copy of each of these files locally (/root/.mailrc & /root/.msmtprc) and system-wide (/etc/mail.rc & /etc/msmtprc)
If I start motion as root from the command line, email is sent as expected.
For my application, I have written a motion.service script that I initiate at boot with systemctl
If I start motion with systemctl, the other part of the event script runs (so I know the script is working), but email is never sent.
I think there must be something simple I am missing. Any ideas?