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

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.

# The place where the mail goes. The actual machine name is required no
# MX records are consulted. Commonly mailhosts are named mail.domain.com

# Where will the mail seem to come from?

# The full hostname

# 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



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.

  • 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 Jan 5 '15 at 14:31
  • 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 Jan 5 '15 at 16:17
  • @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 Jan 5 '15 at 17:07
  • I figured it out. See final edit above. – draugr Jan 6 '15 at 3:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.