1

I am a Ubuntu novice. I've set up ssmtp.

If I run

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

it works. Without sudo it doesn't. It gives Authorization failed 535 Incorrect Authentication

So what difference is sudo making ?

If I can resolve this it will help with a bigger problem of why I can't get a shell script to work - it comes up with the 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

then

  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

Cristiana Nicolae
  • 4,570
  • 10
  • 32
  • 46
Chris W
  • 37

1 Answers1

3

Users are not supposed to run ssmtp directly; use a proper mail user agent such as mail, mailx, or mutt:

echo Test | mailx -s Test foo@bar.baz
fkraiem
  • 12,813