Unable to run script, which emails me results, as super user. (returns: send-mail: 550 5.1.0 Not our Customer)

1

I have been trying to debug this for 2 days now, without success. This is the script I'm trying to run:

#!/bin/bash
emailaddress='my_username@gmail.com'
output=`sudo rsync -av --delete /media/sync/1/backup /media/sync/2/`
echo $output|mail -s "backup_rsync.sh: backup_rsync run" $emailaddress;

I can get the desired results when I run it, directly from the command line or as a cron job, as a regular user. That's why I don't think there is anything wrong with the script itself. The script has the following permissions:

-rwxr--r-- 1 pi pi 190 Jan  4 08:52 scripts/backup_rsync.sh

The problem is when I try to run the same script (different file located in /root) using sudo, or even logged in as root, I get the following results:

send-mail: 550 5.1.0 Not our Customer

These are the permissions for the script located in /root:

-rwxr--r-- 1 root root 190 Jan 4 13:43 /root/backup_rsync.sh

My OS is the latest version Raspbian on my RaspberryPi Model B+. I have installed ssmtp heirloom-mailx to handle email. My ssmtp.conf file is as follows:

#
# Config file for sSMTP sendmail
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
root=my_login@comcast.net

# 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.comcast.net:587

# Where will the mail seem to come from?
rewriteDomain=comcast.net

# The full hostname
hostname=raspberrypi

# 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

UseTLS=Yes
UseSTARTTLS=Yes

AuthUser=my_login
AuthPass=my_password

Where "my_login" and "my_password" are listed above are just fillers. In the real file I have the correct information inserted and, like I said, it works when I email as a regular user. Any help would be appreciated. Let me know if more information is needed.

Edited below for more information

These are the lines from my root crontab:

38 9 * * * /root/backup_rsync.sh >> /tmp/mylog 2>&1
38 9 * * * touch /tmp/my_cronjob_ran1

As you can see, I've been trying to debug this thing. It does produce the "my_cronjob_ran1" file, so I know the root crontab is running. In the "mylog" file is where I get the "send-mail: 550 5.1.0 Not our Customer" message.

Here is the line from my user crontab (the one that is producing the desired results):

00 03 * * * /home/pi/scripts/backup_rsync.sh

Final Edit. I figured out the problem.

I checked the /var/log/syslog and saw these messages when I tried some more testing:

Jan  5 20:07:15 raspberrypi sSMTP[3507]: Creating SSL connection to host
Jan  5 20:07:16 raspberrypi sSMTP[3507]: SSL connection using RSA_AES_128_CBC_SHA1
Jan  5 20:07:17 raspberrypi sSMTP[3507]: Sent mail for pi@comcast.net (221 2.0.0 resomta-ch2-04v.sys.comcast.net comcast closing connection) uid=1000 username=pi outbytes=494

Jan  5 20:07:31 raspberrypi sSMTP[3513]: Creating SSL connection to host
Jan  5 20:07:31 raspberrypi sSMTP[3513]: SSL connection using RSA_AES_128_CBC_SHA1
Jan  5 20:07:32 raspberrypi sSMTP[3513]: Sent mail for pi@comcast.net (221 2.0.0 resomta-ch2-01v.sys.comcast.net comcast closing connection) uid=1000 username=pi outbytes=490

Jan  5 20:09:44 raspberrypi sSMTP[3532]: Creating SSL connection to host
Jan  5 20:09:45 raspberrypi sSMTP[3532]: SSL connection using RSA_AES_128_CBC_SHA1
Jan  5 20:09:46 raspberrypi sSMTP[3532]: 550 5.1.0 Not our Customer

The first 6 lines were me sending a message from my login (pi). The last three lines were me trying to send an email from (root) again. This told me that it was making a connection to Comcast and the error message I was getting was from them. I then opened up Thunderbird on my Windows machine and tried to send a message to root@comcast.net (from my regular email address). I then got this error in Thunderbird:

An error occurred while sending mail. The mail server responded: 5.1.1 Not our Customer. Please check the message recipient root@comcast.net and try again.

So that confirmed the message was coming from Comcast. What I did to fix the problem was I changed this line (rewriteDomain=comcast.net) in my ssmtp.conf file to this (rewriteDomain=gmail.com). Now everything works as it should. I assume it is because Comcast has no way of knowing if it is a valid email address, only that gmail.com is a valid domain.

Thank you to everyone who viewed this and tried to help. If I'm off on my reasoning, or if anyone has anything to add, please let me know.

draugr

Posted 2015-01-04T20:48:22.267

Reputation: 11

Is root getting a different mail command? Try using a full path there. Aside: shouldn't you need to specify TLS keys if you have UseTLS=Yes ? – wurtel – 2015-01-05T14:31:55.283

I added some information above. How do I check if root is getting a different mail command? What should the full path look like? I don't think I need keys for UseTLS=Yes. Mail works on the user login. Forgive my ignorance as I am newer to the linux environment. Thank you and I look to your response. – draugr – 2015-01-05T16:17:27.017

@wurtel Sorry to double comment, but here is something interesting. As user, when I type this (echo "mail from rpi" | mail -s "test3" my_email@comcast.net) in, I get the desired result. When I use sudo before it, I also get the desired result. But, when I am logged in as root, neither command works and it returns the "send-mail: 550 5.1.0 Not our Customer" line. – draugr – 2015-01-05T17:07:07.500

I figured it out. See final edit above. – draugr – 2015-01-06T03:24:40.657

No answers