So a little while ago, one of you helpful people in here gave me a tip when my Raspberry Pi 2 based CRON JOB started up and failed to send emails.
I added MAILTO: pete@scargill.org to whatever I was working on and lo and behold the emails worked.
But now I’ve noted that a daily cron job (etc/cron.daily/logrotate) who’s purpose escapes me – has had a go at sending me an email and that has failed (well, an error email was sent out). The text below is what ended up on my PC in the inbox.
Can anyone who understands this well enough please respond in here with the simplest possible fix that will cover all bases – i.e. any attempts to send emails to me will work without having to pepper “MAILTO:” commands in various places?
Delivery to the following recipient failed permanently:
Delivery to the following recipient failed permanently:
postmaster@raspberrypi
Technical details of permanent failure:
DNS Error: Address resolution of raspberrypi. failed: Domain name not found
—– Original message —–
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=googlemail.com; s=20120113;
h=message-id:sender:from:date:to:subject:content-type;
bh=ufmyvs5OwxMy0Gesn9zW3Sa9V98qRlGmKzu/LxJzxXc=;
b=Il4xP8JOBuSPnPDClGZD2tjzVqo9iPL9OFKBY0sTGLcUEAwHKY5CUTvlnzPpW3U1rL
qZP9dR+STvYsaj5LckFqX5O1U61+aW98SDuIuO8xQHBOpD1JTWJ3P/pX/nAI4Z860W9R
wHBC3N+RVd6VJf4IclJAVZdR93PgCcK+HXmmN/v9A9rYhWSvfR/42bZ1l19L7Mg9x2ov
r6lJT2aOuEc9fW33PFR9ObnQciZCPM5TlQH28c9j73dEUuT2jnyqs5Zo0vjCrF7doF2m
OnQqua9pvrz8dHaQJo1DjVgSYxOmj1lYDE/FBtZECSvqmAoQF/hvQDP+M70S2rv9eZwc
1A0g==
X-Received: by 10.180.86.227 with SMTP id s3mr10918962wiz.58.1423981511381;
Sat, 14 Feb 2015 22:25:11 -0800 (PST)
Return-Path: <peterscargill@googlemail.com>
Received: from raspberrypi ([178.156.122.253])
by mx.google.com with ESMTPSA id jg3sm13818995wid.0.2015.02.14.22.25.09
for <postmaster@raspberrypi>
(version=TLSv1 cipher=RC4-SHA bits=128/128);
Sat, 14 Feb 2015 22:25:10 -0800 (PST)
Message-ID: <54e03bc6.831bb50a.57f4.ffff8e5e@mx.google.com>
Sender: Peter Scargill <peterscargill@googlemail.com>
From: root <pete@scargill.org>
X-Google-Original-From: root (Cron Daemon)
Received: by raspberrypi (sSMTP sendmail emulation); Sun, 15 Feb 2015 06:25:07 +0000
Date: Sun, 15 Feb 2015 06:25:07 +0000
To: root
Subject: Cron <root@raspberrypi> test -x /usr/sbin/anacron || ( cd / && run-parts –report /etc/cron.daily )
Content-Type: text/plain; charset=UTF-8
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin>
X-Cron-Env: <HOME=/root>
X-Cron-Env: <LOGNAME=root>
/etc/cron.daily/logrotate:
apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName
HELP.. I have a new PI installation – bang up to date and I have everything working – I even tested email…. sent myself an email from the command line – that worked…
But… my RAMLOG is not sending me emails at night… and I got an email to say:
Delivery to the following recipient failed permanently:
postmaster@mypi
Technical details of permanent failure:
DNS Error: Address resolution of mypi. failed: Domain name not found
Now, I’ve been into etc/apache2/apache2.conf and put Servername=mypi…..
But I can’t even FIND etc/aliases
Anyone a whiz at this?
And on the question of having email delivered from cron, or anything else on the system…
What you’re doing with the following commands is ensuring that -any- undeliverable mail goes to you directly by updating the “postmaster” address on your Pi.
Edit the file /etc/aliases and replace the “root” in the
postmaster: root
line with the email address that is already working for you with your php crontab entry. – This tells the email system the real-world address of the human who needs to see the email messages.Run “sudo newaliases”. – This tells the mail system to update it’s internal database from the text file you’ve just edited.
Optional:- Use
man -k aliases
to find all of the manual pages which refer to aliases (just in case Raspbian has the file hidden somewhere else) andman newaliases
to get more info on the specific version of the “newaliases” command which Raspbian has installed.Hi PuceBaboon
Erm, well, I found etc/aliases and updated the postmaster entry as your suggestion but when I tried “sudo newaliases” this is what I got.
pi@raspberrypi ~ $ sudo newaliases
newaliases: Aliases are not used in sSMTP
pi@raspberrypi ~ $
Thoughts?
Yup, if it really is sSMPT (I thought that was nailed to the perch, nowadays?) then you should find a config file at /etc/ssmpt/ssmpt.conf.
Near the very top of the file is the line “root=postmaster”. If your update to the alias file didn’t work as expected, you can change the word “postmaster” to be your email address. The easiest way to have it take effect is probably a quick reboot.
So logrotate is a process that does exaclty that, it rotates all of your logs in /var/log* generally on a daily basis although it is configurable, you can look at the various configs in /etc/logrotate.conf and /etc/logrotate.d/
It looks like the error you are getting is due to an Apache config warning. If you look at the /etc/logrotate.d/apache2 configuration for logrotate you will see that after the daily logrotate runs for apache2 it reloads the service. I am pretty sure if you run the command sudo /etc/init.d/apache2 reload it will spit the same warning out.
To fix this you will need to update you apache config located at /etc/apache2/apache2.conf and add a line that says ‘Servername localhost’
Thank you very much, Ben. Pretty much as you described and that particular error message has now gone away. Does make one wonder why that’s not in the basic setup – thousands of beginners setting these things up for the first time probably don’t need messages like that to confuse the issue 🙂