LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-11-2020, 09:59 AM   #1
jorjor242
Member
 
Registered: Apr 2020
Posts: 30

Rep: Reputation: Disabled
error sending email via mutt/msmtp w/ cronjob (status 0x0001 from MTA#012)


his bash script works fine when run from CLI -


Quote:
#!/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.com
However, I tried to install a cronjob to run it daily but it isn't working, this is the job:

# 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:
Apr 10 16:32:01 osboxes CRON[1430]: (root) MAIL (mailed 28 bytes of output but got status 0x0001 from MTA#012)
Apr 10 16:33:01 osboxes CRON[1675]: (root) CMD (root /home/osboxes/Downloads/sendlogzzz.sh)
Apr 10 16:33:02 osboxes CRON[1674]: (root) MAIL (mailed 28 bytes of output but got status 0x0001 from MTA#012)
Apr 10 16:34:01 osboxes CRON[1932]: (root) CMD (root /home/osboxes/Downloads/sendlogzzz.sh)
Apr 10 16:34:01 osboxes CRON[1931]: (root) MAIL (mailed 28 bytes of output but got status 0x0001 from MTA#012)

This is my ssmtp config:

Quote:
root=postmaster
SERVER=xxx@gmail.com

# The place where the mail goes. The actual machine name is required no
# MX records are consulted. Commonly mailhosts are named mail.domain.com
mailhub=smtp.gmail.com:587

AuthUser=xxx@gmail.com
AuthPass=xxx
UseTLS=YES
UseSTARTTLS=YES

# Where will the mail seem to come from?
rewriteDomain=gmail.com

# The full hostname
hostname=osboxes.lan

# Are users allowed to set their own From: address?
# YES - Allow the user to specify their own From: address
# NO - Use the system generat

Based on what I've read on other threads it looks like the proper format...not sure what to troubleshoot

Last edited by jorjor242; 04-11-2020 at 10:01 AM. Reason: adding config
 
Old 04-12-2020, 04:18 AM   #2
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,670

Rep: Reputation: Disabled
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

Last edited by shruggy; 04-12-2020 at 07:05 AM.
 
Old 04-12-2020, 10:58 AM   #3
jorjor242
Member
 
Registered: Apr 2020
Posts: 30

Original Poster
Rep: Reputation: Disabled
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:
Apr 12 09:04:02 osboxes sSMTP[9195]: (osboxes.lan)
Apr 12 09:05:01 osboxes sSMTP[9434]: (osboxes.lan)
Apr 12 09:06:01 osboxes sSMTP[9676]: (osboxes.lan)
Apr 12 09:07:01 osboxes sSMTP[9920]: (osboxes.lan)
Apr 12 09:08:01 osboxes sSMTP[10163]: (osboxes.lan)
Apr 12 09:09:01 osboxes sSMTP[10407]: (osboxes.lan)
Apr 12 09:10:02 osboxes sSMTP[10648]: (osboxes.lan)
Apr 12 09:11:01 osboxes sSMTP[10888]: (osboxes.lan)
Apr 12 09:12:01 osboxes sSMTP[11131]: (osboxes.lan)
Apr 12 09:13:01 osboxes sSMTP[11372]: (osboxes.lan)
Apr 12 09:14:01 osboxes sSMTP[11616]: (osboxes.lan)
Apr 12 09:15:01 osboxes sSMTP[11859]: (osboxes.lan)
Apr 12 09:16:02 osboxes sSMTP[12101]: (osboxes.lan)
Apr 12 09:17:01 osboxes sSMTP[12342]: (osboxes.lan)
Apr 12 09:18:01 osboxes sSMTP[12587]: (osboxes.lan)

In mail.log, the errors were consistently the same:
Quote:
Apr 12 11:49:01 osboxes sSMTP[17339]: Unable to set SERVER="xxx@gmail.com"
Apr 12 11:49:01 osboxes sSMTP[17339]: Creating SSL connection to host
Apr 12 11:49:01 osboxes sSMTP[17339]: 220 smtp.gmail.com ESMTP q11sm6256000qkq.109 - gsmtp
Apr 12 11:49:01 osboxes sSMTP[17339]: EHLO osboxes.lan
Apr 12 11:49:01 osboxes sSMTP[17339]: 250 SMTPUTF8
Apr 12 11:49:01 osboxes sSMTP[17339]: STARTTLS
Apr 12 11:49:01 osboxes sSMTP[17339]: 220 2.0.0 Ready to start TLS
Apr 12 11:49:01 osboxes sSMTP[17339]: SSL connection using ECDHE_RSA_AES_256_GCM_SHA384
Apr 12 11:49:01 osboxes sSMTP[17339]: EHLO osboxes.lan
Apr 12 11:49:01 osboxes sSMTP[17339]:
Apr 12 11:49:01 osboxes sSMTP[17339]: (osboxes.lan)
Apr 12 11:50:01 osboxes sSMTP[17594]: Unable to set SERVER="xxx@gmail.com"
Apr 12 11:50:01 osboxes sSMTP[17594]: Creating SSL connection to host
Apr 12 11:50:01 osboxes sSMTP[17594]: 220 smtp.gmail.com ESMTP 63sm757492qkl.64 - gsmtp
Apr 12 11:50:01 osboxes sSMTP[17594]: EHLO osboxes.lan
Apr 12 11:50:01 osboxes sSMTP[17594]: 250 SMTPUTF8
Apr 12 11:50:01 osboxes sSMTP[17594]: STARTTLS
Apr 12 11:50:01 osboxes sSMTP[17594]: 220 2.0.0 Ready to start TLS
Apr 12 11:50:01 osboxes sSMTP[17594]: SSL connection using ECDHE_RSA_AES_256_GCM_SHA384
Apr 12 11:50:01 osboxes sSMTP[17594]: EHLO osboxes.lan

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??

Last edited by jorjor242; 04-12-2020 at 11:15 AM.
 
Old 04-12-2020, 11:17 AM   #4
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,670

Rep: Reputation: Disabled
Quote:
Originally Posted by jorjor242 View Post
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
I'm really confused now. Is it msmtp or ssmtp? The config file you've shown is clearly /etc/ssmtp/ssmtp.conf. The configuration for msmtp lives in msmtprc though.
 
Old 04-12-2020, 12:00 PM   #5
jorjor242
Member
 
Registered: Apr 2020
Posts: 30

Original Poster
Rep: Reputation: Disabled
I edited the ssmtp config, but I also have msmtp installed and this is the file:

Quote:
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 account2
This is the ssmtp config, root, SERVER, and AuthUser are all the same gmail acc:

Quote:
#
# Config file for sSMTP sendmail
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
root=xxx@gmail.com
SERVER=xxx@gmail.com

# The place where the mail goes. The actual machine name is required no
# MX records are consulted. Commonly mailhosts are named mail.domain.com
mailhub=smtp.gmail.com:587

AuthUser=xxx@gmail.com
AuthPass=xx
UseTLS=YES
UseSTARTTLS=YES

# Where will the mail seem to come from?
rewriteDomain=gmail.com

# The full hostname
hostname=osboxes.lan

# Are users allowed to set their own From: address?
# YES - Allow the user to specify their own From: address
# NO - Use the system generated From: address
FromLineOverride=YES
Debug=YES

I havne't done anything to the revaliases file for ssmtp:

Quote:
# sSMTP aliases
#
# Format: local_accountutgoing_address:mailhub
#
# Example: root:your_login@your.domain:mailhub.your.domain[ort]
# where [ort] is an optional port number that defaults to 25.




This is the error I keep getting from syslog:

Quote:
Apr 12 12:51:01 osboxes cron[623]: sendmail: (osboxes.lan)
Apr 12 12:51:01 osboxes sSMTP[32422]: (osboxes.lan)
Apr 12 12:51:01 osboxes CRON[32420]: (root) MAIL (mailed 28 bytes of output but got status 0x0001 from MTA#012)
Apr 12 12:51:20 osboxes filebeat[830]: 2020-04-12T12:51:20.072-0400#011INFO#011[monitoring]#011log/log.go:145#011Non-zero metrics in the last 30s#011{"monitoring": {"metrics": {"beat":{"cpu":{"system":>
Apr 12 12:51:50 osboxes filebeat[830]: 2020-04-12T12:51:50.073-0400#011INFO#011[monitoring]#011log/log.go:145#011Non-zero metrics in the last 30s#011{"monitoring": {"metrics": {"beat":{"cpu":{"system":>
Apr 12 12:52:01 osboxes CRON[32667]: (root) CMD (root /home/osboxes/Downloads/sendlogzzz.sh)
Apr 12 12:52:01 osboxes sSMTP[32668]: Unable to set SERVER="xxx@gmail.com"
Apr 12 12:52:02 osboxes sSMTP[32668]: Creating SSL connection to host
Apr 12 12:52:02 osboxes sSMTP[32668]: 220 smtp.gmail.com ESMTP w30sm6657831qtw.21 - gsmtp
Apr 12 12:52:02 osboxes sSMTP[32668]: EHLO osboxes.lan
Apr 12 12:52:02 osboxes sSMTP[32668]: 250 SMTPUTF8
Apr 12 12:52:02 osboxes sSMTP[32668]: STARTTLS
Apr 12 12:52:02 osboxes sSMTP[32668]: 220 2.0.0 Ready to start TLS
Apr 12 12:52:02 osboxes sSMTP[32668]: SSL connection using ECDHE_RSA_AES_256_GCM_SHA384
Apr 12 12:52:02 osboxes sSMTP[32668]: EHLO osboxes.lan
Apr 12 12:52:02 osboxes sSMTP[32668]:
Apr 12 12:52:02 osboxes cron[623]: sendmail: (osboxes.lan)
Apr 12 12:52:02 osboxes sSMTP[32668]: (osboxes.lan)

Last edited by jorjor242; 04-13-2020 at 12:03 PM. Reason: sanitized
 
Old 04-12-2020, 12:44 PM   #6
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,670

Rep: Reputation: Disabled
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.
 
Old 04-12-2020, 03:01 PM   #7
jorjor242
Member
 
Registered: Apr 2020
Posts: 30

Original Poster
Rep: Reputation: Disabled
This is my config file for Muttrc in /etc, I don't think I change anything.. :

Quote:
# System configuration file for Mutt
#

# Default list of header fields to weed when displaying.
# Ignore all lines by default...
ignore *

# ... then allow these through.
unignore from: subject to cc date x-mailer x-url user-agent

# Display the fields in this order
hdr_order date from to cc subject

# emacs-like bindings
bind editor "\e<delete>" kill-word
bind editor "\e<backspace>" kill-word

# map delete-char to a sane value
bind editor <delete> delete-char

# some people actually like these settings
#set pager_stop
#bind pager <up> previous-line
#bind pager <down> next-line

# Specifies how to sort messages in the index menu.
set sort=threads

# The behavior of this option on the Debian mutt package is
# not the original one because exim4, the default SMTP on Debian
# does not strip bcc headers so this can cause privacy problems;
# see man muttrc for more info
#unset write_bcc
# Postfix and qmail use Delivered-To for detecting loops
unset bounce_delivered

set mixmaster="mixmaster-filter"

# System-wide CA file managed by the ca-certificates package
set ssl_ca_certificates_file="/etc/ssl/certs/ca-certificates.crt"

# imitate the old search-body function
macro index \eb "<search>~b " "search in message bodies"

# simulate the old url menu
macro index,pager,attach,compose \cb "\
<enter-command> set my_pipe_decode=\$pipe_decode pipe_decode<Enter>\
<pipe-message> urlview<Enter>\
<enter-command> set pipe_decode=\$my_pipe_decode; unset my_pipe_decode<Enter>" \
"call urlview to extract URLs out of a message"

# Show documentation when pressing F1
macro generic,pager <F1> "<shell-escape> zcat /usr/share/doc/mutt/manual.txt.gz | sensible-pager<enter>" "show Mutt documentation"

# show the incoming mailboxes list (just like "mutt -y") and back when pressing "y"
macro index y "<change-folder>?<toggle-mailboxes>" "show incoming mailboxes list"
macro pager y "<exit><change-folder>?<toggle-mailboxes>" "show incoming mailboxes list"
bind browser y exit

# Handler for gzip compressed mailboxes
# open-hook '\.gz$' "gzip -cd '%f' > '%t'"
# close-hook '\.gz$' "gzip -c '%t' > '%f'"
# append-hook '\.gz$' "gzip -c '%t' >> '%f'"

# If Mutt is unable to determine your site's domain name correctly, you can
# set the default here. (better: fix /etc/mailname)
#
# set hostname=cs.hmc.edu

# If your sendmail supports the -B8BITMIME flag, enable the following
#
# set use_8bitmime

# Use mime.types to look up handlers for application/octet-stream. Can
# be undone with unmime_lookup.
mime_lookup application/octet-stream

# Upgrade the progress counter every 250ms, good for mutt over SSH
# see http://bugs.debian.org/537746
set time_inc=250

# Allow mutt to understand References, Cc and In-Reply-To as headers in mailto:
mailto_allow = cc in-reply-to references

##
## *** DEFAULT SETTINGS FOR THE ATTACHMENTS PATCH ***
##

##
## Please see the manual (section "attachments") for detailed
## documentation of the "attachments" command.
##
## Removing a pattern from a list removes that pattern literally. It
## does not remove any type matching the pattern.
##
## attachments +A */.*
## attachments +A image/jpeg
## unattachments +A */.*
##
## This leaves "attached" image/jpeg files on the allowed attachments
## list. It does not remove all items, as you might expect, because the
## second */.* is not a matching expression at this time.
##
## Remember: "unattachments" only undoes what "attachments" has done!
## It does not trigger any matching on actual messages.

## Qualify any MIME part with an "attachment" disposition, EXCEPT for
## text/x-vcard and application/pgp parts. (PGP parts are already known
## to mutt, and can be searched for with ~g, ~G, and ~k.)
##
## I've added x-pkcs7 to this, since it functions (for S/MIME)
## analogously to PGP signature attachments. S/MIME isn't supported
## in a stock mutt build, but we can still treat it specially here.
##
attachments +A */.*
attachments -A text/x-vcard application/pgp.*
attachments -A application/x-pkcs7-.*

## Discount all MIME parts with an "inline" disposition, unless they're
## text/plain. (Why inline a text/plain part unless it's external to the
## message flow?)
##
attachments +I text/plain

## These two lines make Mutt qualify MIME containers. (So, for example,
## a message/rfc822 forward will count as an attachment.) The first
## line is unnecessary if you already have "attach-allow */.*", of
## course. These are off by default! The MIME elements contained
## within a message/* or multipart/* are still examined, even if the
## containers themselves don't qualify.
##
#attachments +A message/.* multipart/.*
#attachments +I message/.* multipart/.*

## You probably don't really care to know about deleted attachments.
attachments -A message/external-body
attachments -I message/external-body

##
# See /usr/share/doc/mutt/README.Debian for details.
source /usr/lib/mutt/source-muttrc.d|
Is there something I need to change in /etc/Muttrc.d?

odd, my /etc/Muttrc file does not look like this one - https://gist.github.com/jaysonrowe/2624926

Last edited by jorjor242; 04-12-2020 at 06:54 PM.
 
Old 04-13-2020, 02:05 AM   #8
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,670

Rep: Reputation: Disabled
Quote:
Originally Posted by jorjor242 View Post
Is there something I need to change in /etc/Muttrc.d?
If there're any *.rc files beyond charset.rc, colors.rc, compressed-folders.rc, gpg.rc, and smime.rc installed by Debian mutt package then probably yes.

Quote:
odd, my /etc/Muttrc file does not look like this one - https://gist.github.com/jaysonrowe/2624926
The config you linked above speaks to Gmail directly: with such setup a local MTA is completely unnecessary, neither msmtp nor ssmtp nor anything else. Your Muttrc though doesn't set smtp_url nor sendmail explicitly, that means it uses /usr/sbin/sendmail by default.

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
ssmtp doesn't know about keyword SERVER. Where did you get it from?

Quote:
Originally Posted by jorjor242 View Post
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??
Yes, this may be an issue. No, you shouldn't include the IP. What is the output of commands hostname --fqdn, host $(hostname) and hostnamectl status?

Last edited by shruggy; 04-13-2020 at 02:52 AM.
 
Old 04-13-2020, 05:09 PM   #9
jorjor242
Member
 
Registered: Apr 2020
Posts: 30

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by shruggy View Post
If there're any *.rc files beyond charset.rc, colors.rc, compressed-folders.rc, gpg.rc, and smime.rc installed by Debian mutt package then probably yes.


The config you linked above speaks to Gmail directly: with such setup a local MTA is completely unnecessary, neither msmtp nor ssmtp nor anything else. Your Muttrc though doesn't set smtp_url nor sendmail explicitly, that means it uses /usr/sbin/sendmail by default.

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
ssmtp doesn't know about keyword SERVER. Where did you get it from?

Yes, this may be an issue. No, you shouldn't include the IP. What is the output of commands hostname --fqdn, host $(hostname) and hostnamectl status?
there are no more .rc files/directories fortunately!

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...
 
Old 04-14-2020, 08:01 AM   #10
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,670

Rep: Reputation: Disabled
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.
 
Old 04-14-2020, 02:24 PM   #11
jorjor242
Member
 
Registered: Apr 2020
Posts: 30

Original Poster
Rep: Reputation: Disabled
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:
* * * * * osboxes /home/osboxes/Downloads/sendlogzzz.sh
Still getting this error in mail.log

"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:
Apr 14 15:24:01 osboxes CRON[30536]: (root) CMD (osboxes /home/osboxes/Downloads/sendlogzzz.sh)

osboxes CRON[30535]: (root) MAIL (mailed 31 bytes of output but got status 0x0001 from MTA#012)


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:
Apr 14 15:28:01 osboxes sSMTP[31512]: (osboxes.lan)
Apr 14 15:29:01 osboxes sSMTP[31755]: Creating SSL connection to host
Apr 14 15:29:01 osboxes sSMTP[31755]: 220 smtp.gmail.com ESMTP n185sm2047140qke.82 - gsmtp
Apr 14 15:29:01 osboxes sSMTP[31755]: EHLO osboxes.lan
Apr 14 15:29:01 osboxes sSMTP[31755]: 250 SMTPUTF8
Apr 14 15:29:01 osboxes sSMTP[31755]: STARTTLS
Apr 14 15:29:01 osboxes sSMTP[31755]: 220 2.0.0 Ready to start TLS
Apr 14 15:29:01 osboxes sSMTP[31755]: SSL connection using ECDHE_RSA_AES_256_GCM_SHA384
Apr 14 15:29:01 osboxes sSMTP[31755]: EHLO osboxes.lan
Apr 14 15:29:01 osboxes sSMTP[31755]:
Apr 14 15:29:01 osboxes sSMTP[31755]: (osboxes.lan)
Apr 14 15:30:01 osboxes sSMTP[32001]: Creating SSL connection to host
Apr 14 15:30:01 osboxes sSMTP[32001]: 220 smtp.gmail.com ESMTP c27sm11820184qte.49 - gsmtp
Apr 14 15:30:01 osboxes sSMTP[32001]: EHLO osboxes.lan
Apr 14 15:30:01 osboxes sSMTP[32001]: 250 SMTPUTF8
Apr 14 15:30:01 osboxes sSMTP[32001]: STARTTLS
Apr 14 15:30:01 osboxes sSMTP[32001]: 220 2.0.0 Ready to start TLS
Apr 14 15:30:01 osboxes sSMTP[32001]: SSL connection using ECDHE_RSA_AES_256_GCM_SHA384
Apr 14 15:30:01 osboxes sSMTP[32001]: EHLO osboxes.lan
Apr 14 15:30:01 osboxes sSMTP[32001]:
Apr 14 15:30:01 osboxes sSMTP[32001]: (osboxes.lan)

Last edited by jorjor242; 04-14-2020 at 02:32 PM.
 
Old 04-14-2020, 03:19 PM   #12
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,670

Rep: Reputation: Disabled
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.
 
Old 04-14-2020, 03:51 PM   #13
jorjor242
Member
 
Registered: Apr 2020
Posts: 30

Original Poster
Rep: Reputation: Disabled
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..
 
Old 04-14-2020, 04:06 PM   #14
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,732

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
Quote:
Originally Posted by jorjor242 View Post
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..
Please post the script you’re running via cron. Please use code tags
 
Old 04-14-2020, 07:33 PM   #15
jorjor242
Member
 
Registered: Apr 2020
Posts: 30

Original Poster
Rep: Reputation: Disabled
Thanks for assisting scasey!

Code:
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" -- xxx@gmail.com
I don't have any trouble sending an email with that mutt command, it just won't work in the bash script

the cronjob:

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

Last edited by jorjor242; 04-14-2020 at 07:36 PM.
 
  


Reply

Tags
cronjob, email, mutt, ssmtp



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Sending security alert logs with msmtp/ssmtp/mutt jorjor242 Linux - Newbie 1 04-10-2020 03:33 PM
Why mutt can send email but msmtp can't? luofeiyu Linux - Server 1 07-29-2017 08:27 PM
[SOLVED] Connection Refused error while sending mail using mutt and msmtp Iyyappan Linux - Server 2 06-30-2012 04:49 AM
msmtp/mutt trouble sending mail (server message: 451 4.4.1) Phieth6o Linux - Software 1 12-23-2009 02:23 PM
cmdline: Sending email without mutt and with msmtp something? frenchn00b Linux - Newbie 3 03-02-2008 01:11 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:50 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration