Article 52C7S Sendmail and recognized root not dispatching email via chronjob on Ubuntu

Sendmail and recognized root not dispatching email via chronjob on Ubuntu

by
jorjor242
from LinuxQuestions.org on (#52C7S)
I set up the follow cronjob to send security events from Suricata in an email:

Code:#!/bin/bash

tail -n 50 /var/log/suricata/fast.log > "$(date '+%Y-%m-%d_%H-%M-%S').log"

echo "Hello this is the body message, we are sending email with attachement using mutt and msmtp" | mutt -a /home/osboxes/Downloads/"$(date '+%Y-%m-%d_%H-%M-%S').log" -s "this is the subject of the message" -- xxxx@gmail.comThis is the cronjob:

* * * * * sudo su /home/osboxes/Downloads/sendlogzzz.sh


The mutt and msmtp part of the cronjob works fine when I do it manually from CLI just not in the chronjob..

But am running into a problem reflected in syslog:

Code:Apr 19 13:04:01 osboxes CRON[24524]: (root) CMD (sudo su /home/osboxes/Downloads/sendlogzzz.sh)
Apr 19 13:04:02 osboxes cron[497]: sendmail: recipient address root not accepted by the server
Apr 19 13:04:02 osboxes cron[497]: sendmail: server message: 553 5.1.3 The recipient address <root> is not a valid RFC-5321 address. b10sm21732463qtj.30 - gsmtp
Apr 19 13:04:02 osboxes cron[497]: sendmail: could not send mail (account default from /etc/msmtprc)
Apr 19 13:04:02 osboxes CRON[24523]: (root) MAIL (mailed 62 bytes of output but got status 0x0041 from MTA#012)This problem resembles this - http://www.linux-databook.info/?page_id=2898 , but I uninstalled and purged sendmail according to this https://askubuntu.com/questions/4608...emove-sendmail using a *

logs from auth.log:

Code:osboxes CRON[25493]: pam_unix(cron:session): session closed for user root
Apr 19 13:09:01 osboxes CRON[25733]: pam_unix(cron:session): session opened for user root by (uid=0)
Apr 19 13:09:01 osboxes sudo: root : TTY=unknown ; PWD=/root ; USER=root ; COMMAND=/usr/bin/su /home/osboxes/Downloads/sendlogzzz.sh
Apr 19 13:09:01 osboxes sudo: pam_unix(sudo:session): session opened for user root by (uid=0)
Apr 19 13:09:01 osboxes sudo: pam_unix(sudo:session): session closed for user root
Apparmor had been a problem originally so I disabled it.

This is my msmtprc in /etc:

Code:account default
host smtp.gmail.com
port 587
logfile /tmp/msmtp.log
tls on
tls_starttls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt

auth login
user xxx@gmail.com
password xxx
from First Last Name

account account2latest?d=yIl2AUoC8zA latest?i=tsg3UNHADLQ:rNBT2tlF5RU:F7zBnMy latest?i=tsg3UNHADLQ:rNBT2tlF5RU:V_sGLiP latest?d=qj6IDK7rITs latest?i=tsg3UNHADLQ:rNBT2tlF5RU:gIN9vFwtsg3UNHADLQ
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments