cron - Why does ssmtp work with sudo but not without? - Ask Ubuntu


i ubuntu novice. i've set ssmtp.

if run

echo "mail test" | sudo ssmtp -vvv xxxxxxxx@domainname.com  

it works. without sudo doesn't. gives authorization failed 535 incorrect authentication

so difference sudo making ?

if can resolve bigger problem of why can't shell script work - comes same error.

testscript

ssmtp.conf :- root=xxxxxxxx@domainname.com mailhub=auth.smtp.vvvvvvv.co.uk usetls=yes fromlineoverride=yes usestarttls=yes authuser=xxxxxxxx@domainname.com authpass=pppppppp rewritedomain=domainname.com authmethod=login tls_ca_file=/home/username/cert.pem 

testscript shell script

#!/bin/sh  today=$(date)  echo "test script running $today" >> /home/username/documents/testfile.log  if ssmtp xxxxxxxx@domainname.com < testscript.txt     echo "test script complete" >> /home/username/documents/testfile.log  else    echo "test script failed" >> /home/username/documents/testfile.log   echo "test script ended" >> /home/username/documents/testfile.log 

testscript.txt

to:xxxxxxxx@domainname.com from:xxxxxxxx.domainname.com  subject:mail test mime-version:1.0  content-type:text/plain 

auto email test

users not supposed run ssmtp directly; use proper mail user agent such mail, mailx, or mutt:

echo test | mailx -s test foo@bar.baz 

Comments

Popular posts from this blog

download - Firefox cannot save files (most of the time), how to solve? - Super User

windows - "-2146893807 NTE_NOT_FOUND" when repair certificate store - Super User

sql server - "Configuration file does not exist", Event ID 274 - Super User