error sending email via mutt/msmtp w/ cronjob (status 0x0001 from MTA#012)
his bash script works fine when run from CLI -
Quote:
# m h dom mon dow command * * * * * root /home/osboxes/Downloads/sendlogzzz.sh sudo crontab -l : # m h dom mon dow command * * * * * root /home/osboxes/Downloads/sendlogzzz.sh (I intentionally set it to send every minute to see if it would work). I looked sudo grep CRON /var/log/syslog : Quote:
This is my ssmtp config: Quote:
Based on what I've read on other threads it looks like the proper format...not sure what to troubleshoot |
Try adding Debug=YES to your ssmtp.conf. This will give you more info in the logs. Could it be that smtp.gmail.com rejects emails sent from root?
Also, check this page in ArchWiki. Instead of root=postmaster I'd expect root=xxx@gmail.com and FromLineOverride=YES |
I made the changes in the config that you suggested -
when I just run the sendlogzzz.sh from CLI in verbose it gives me an error related to /tmp/msmtp.log but it sends the logs: bash sendlogzzz.sh -v msmtp: cannot log to /tmp/msmtp.log: cannot lock (tried for 10 seconds): Permission denied msmtp: log info was: host=smtp.gmail.com tls=on auth=on user=xxx@gmail.com from=xxx@gmail.com recipients=xxx@gmail.com mailsize=669 smtpstatus=250 smtpmsg='250 2.0.0 OK 1586706197 o18sm6025147qkk.52 - gsmtp' exitcode=EX_OK In the /var/log/mail.err logs, I occasionally get this error every 20 logs or so: Apr 12 09:00:01 osboxes sSMTP[8222]: Authorization failed (535 5.7.8 https://support.google.com/mail/?p=BadCredentials n63sm5884865qka.80 - gsmtp) But the rest look like this: Quote:
In mail.log, the errors were consistently the same: Quote:
I have the recipient and sender set to same address but that shouldn't matter I don't think... should I remove root from the chronjob? I've read differing instructions: * * * * * root /home/osboxes/Downloads/sendlogzzz.sh Maybe this is the issue? On the arch page it says "# The full hostname. Must be correctly formed, fully qualified domain name or GMail will reject connection. hostname=yourlocalhost.yourlocaldomain.tld" mine is: hostname=osboxes.lan Should I include the local IP before osboxes.lan?? |
Quote:
|
I edited the ssmtp config, but I also have msmtp installed and this is the file:
Quote:
Quote:
I havne't done anything to the revaliases file for ssmtp: Quote:
This is the error I keep getting from syslog: Quote:
|
Wait, how is mutt configured to send messages? Did you set either sendmail or smtp_url in your muttrc file to some value? Or is it using the default (/usr/sbin/sendmail)? Then where does that point to? On many distributions, it's a symbolic link managed through alternatives system.
|
This is my config file for Muttrc in /etc, I don't think I change anything.. :
Quote:
odd, my /etc/Muttrc file does not look like this one - https://gist.github.com/jaysonrowe/2624926 |
Quote:
Quote:
Please show the output of readlink -e /usr/sbin/sendmail Also, please sanitize the syslog output from your post #5. It shows your real email address. Further, there's this line in your ssmtp config: Code:
SERVER=xxx@gmail.com Quote:
|
Quote:
Output: readlink -e /usr/sbin/sendmail: /usr/sbin/ssmtp I don't know where I got SERVER=xxx@gmail.com from, probably a tutorial - should I delete/comment out the line? Outputs: hostname --fqdn osboxes host $(hostname) osboxes.lan has address 192.168.1.102 hostnamectl status Static hostname: osboxes Icon name: computer-vm Chassis: vm Machine ID: xxxxx Boot ID: xxxx Virtualization: oracle Operating System: Ubuntu 19.10 Kernel: Linux 5.3.0-46-generic Architecture: x86-64 Thank you so much for helping thus far, it is very confusing getting these overlapping programs to work with info on the internet which can be contradictory... |
Could it be that mutt for user osboxes configured quite differently compared to root? I mean /home/osboxes/.muttrc or /home/osboxes/.mutt/muttrc, whichever you have? Try to change the username field in crontab to that user and see if you can get mails off your system then.
|
those are not located in my /home/osboxes directory, even when I do an "-ls a". The muttrc file is in the /etc directory - is that a potential issue?
This is the cronjob now: Quote:
"Unable to set SERVER="xxx@gmail.com" So commented out that line in the ssmtp.config - now testing, no go - still getting these errors in syslog, even with osboxes in the crontab: Quote:
from mail.err: Apr 14 15:09:02 osboxes sSMTP[26119]: (osboxes.lan) Apr 14 15:10:02 osboxes sSMTP[26761]: (osboxes.lan) Apr 14 15:11:01 osboxes sSMTP[27007]: (osboxes.lan) Apr 14 15:12:01 osboxes sSMTP[27279]: (osboxes.lan) Apr 14 15:13:02 osboxes sSMTP[27596]: (osboxes.lan) Apr 14 15:14:01 osboxes sSMTP[28013]: (osboxes.lan) Apr 14 15:15:01 osboxes sSMTP[28285]: (osboxes.lan) Apr 14 15:16:02 osboxes sSMTP[28539]: (osboxes.lan) Apr 14 15:17:01 osboxes sSMTP[28781]: (osboxes.lan) Apr 14 15:18:01 osboxes sSMTP[29024]: (osboxes.lan) Apr 14 15:19:01 osboxes sSMTP[29274]: (osboxes.lan) Apr 14 15:20:01 osboxes sSMTP[29524]: (osboxes.lan) Apr 14 15:21:01 osboxes sSMTP[29787]: (osboxes.lan) Apr 14 15:22:02 osboxes sSMTP[30037]: (osboxes.lan) Apr 14 15:23:01 osboxes sSMTP[30283]: (osboxes.lan) Apr 14 15:24:01 osboxes sSMTP[30537]: (osboxes.lan) Apr 14 15:25:01 osboxes sSMTP[30784]: (osboxes.lan) Apr 14 15:26:01 osboxes sSMTP[31027]: (osboxes.lan) Apr 14 15:27:02 osboxes sSMTP[31269]: (osboxes.lan) From mail.log, it gets to 220 but not 250 for authentication: Quote:
|
I'm not sure, but it seems to me that when you're running the script from command line the mail gets relayed via msmtp. Could you please show the output of mutt -D|grep sendmail= ?
You also could try sudo apt install msmtp-mta This will force uninstalling ssmtp and make the symlink /usr/sbin/sendmail point to msmtp instead. I also found this thread in Zimbra forum. It's pretty old and I'm not sure if it applies here, but it suggests that you may have problems sending emails to Gmail if you're on a dynamic DNS. |
mutt -D|grep sendmail=
sendmail="/usr/bin/msmtp" I will try the sudo apt install msmtp-mta as next step. And I haven't had problems sending the email to the Gmail via CLI, just view the cronjob.. |
Quote:
|
Thanks for assisting scasey!
Code:
tail -n 50 /var/log/suricata/fast.log > "$(date '+%Y-%m-%d_%H-%M-%S').log" the cronjob: * * * * * osboxes /home/osboxes/Downloads/sendlogzzz.sh |
All times are GMT -5. The time now is 08:42 PM. |