Candyjet
Posts: 66
Joined: Sun Jan 10, 2016 3:45 pm

MSMTPRC default account settings

Mon Mar 27, 2023 3:58 pm

Hi,

I'm trying to get my Pi to take a photo and email it to me on boot up.
I can run a python script which will do exactly as I want, the problem comes when trying to run it automatically on boot using crontab.

I have attached the boot log below. What is baffling me is references to 2 different email settings, particularly those referring to mail.btinternet.com.

I initially set the etc/msmtprc file with mail.btinternet.com settings. When that did not work, I switched to send.one.com settings, which work fine when running the python script.

The question really is about where the pi is getting that mail.btinternet.com stuff from, as it most certainly is not mentioned in my etc/msmtprc file?


Thanks,

CJ

Code: Select all

Mar 27 15:54:04 raspberrypi crontab[1568]: (root) BEGIN EDIT (root)
Mar 27 15:56:44 raspberrypi crontab[1568]: (root) REPLACE (root)
Mar 27 15:56:44 raspberrypi crontab[1568]: (root) END EDIT (root)
Mar 27 15:57:01 raspberrypi cron[394]: (CRON) INFO (pidfile fd = 3)
Mar 27 15:57:01 raspberrypi cron[394]: (CRON) INFO (Running @reboot jobs)
Mar 27 15:57:03 raspberrypi cron[601]: sendmail: cannot locate host mail.btinternet.com: Temporary failure in name resolution
Mar 27 15:57:03 raspberrypi cron[601]: sendmail: could not send mail (account default from /etc/msmtprc)
Mar 27 15:59:21 raspberrypi crontab[1379]: (root) BEGIN EDIT (root)
Mar 27 15:59:58 raspberrypi crontab[1379]: (root) REPLACE (root)
Mar 27 15:59:58 raspberrypi crontab[1379]: (root) END EDIT (root)
Mar 27 16:00:01 raspberrypi cron[394]: (root) RELOAD (crontabs/root)
Mar 27 16:02:10 raspberrypi crontab[1431]: (root) BEGIN EDIT (root)
Mar 27 16:02:15 raspberrypi crontab[1431]: (root) END EDIT (root)
Mar 27 16:02:19 raspberrypi crontab[1437]: (root) BEGIN EDIT (root)
Mar 27 16:03:34 raspberrypi crontab[1437]: (root) REPLACE (root)
Mar 27 16:03:34 raspberrypi crontab[1437]: (root) END EDIT (root)
Mar 27 16:03:48 raspberrypi cron[391]: (CRON) INFO (pidfile fd = 3)
Mar 27 16:03:48 raspberrypi cron[391]: (CRON) INFO (Running @reboot jobs)
Mar 27 16:03:55 raspberrypi cron[773]: sendmail: cannot connect to mail.btinternet.com, port 465: Network is unreachable
Mar 27 16:03:55 raspberrypi cron[773]: sendmail: could not send mail (account default from /etc/msmtprc)
Mar 27 16:17:01 raspberrypi CRON[1581]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Mar 27 16:25:51 raspberrypi cron[366]: (CRON) INFO (pidfile fd = 3)
Mar 27 16:25:51 raspberrypi cron[366]: (CRON) INFO (Running @reboot jobs)
Mar 27 16:25:58 raspberrypi cron[774]: sendmail: cannot connect to send.one.com, port 587: Network is unreachable
Mar 27 16:25:58 raspberrypi cron[774]: sendmail: could not send mail (account default from /etc/msmtprc)
Mar 27 16:33:48 raspberrypi crontab[1491]: (root) BEGIN EDIT (root)
Mar 27 16:39:16 raspberrypi cron[380]: (CRON) INFO (pidfile fd = 3)
Mar 27 16:39:16 raspberrypi cron[380]: (CRON) INFO (Running @reboot jobs)
Mar 27 16:39:24 raspberrypi cron[782]: sendmail: cannot connect to send.one.com, port 587: Network is unreachable
Mar 27 16:39:24 raspberrypi cron[782]: sendmail: could not send mail (account default from /etc/msmtprc)

User avatar
scruss
Posts: 5375
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON

Re: MSMTPRC default account settings

Mon Mar 27, 2023 4:36 pm

The btinternet entries are old. Everything before the 16:33:48 "BEGIN EDIT" line is old and irrelevant.

You will have to enable "wait for network at boot" using raspi-config, as your crontab is starting the mail process long before the network is up. That's why the one.com attempt doesn't work: "Network is unreachable"
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him

Candyjet
Posts: 66
Joined: Sun Jan 10, 2016 3:45 pm

Re: MSMTPRC default account settings

Mon Mar 27, 2023 5:28 pm

Brilliant, thanks.
I’ll give it a go.

User avatar
jojopi
Posts: 3737
Joined: Tue Oct 11, 2011 8:38 pm

Re: MSMTPRC default account settings

Mon Mar 27, 2023 5:47 pm

Candyjet wrote:
Mon Mar 27, 2023 3:58 pm
I'm trying to get my Pi to take a photo and email it to me on boot up.
I can run a python script which will do exactly as I want, the problem comes when trying to run it automatically on boot using crontab.
In case you had not realized, the errors in the log are nothing to do with the photo email you are trying to send. They relate to emails that cron itself wanted to send to inform a user of the output from one of their jobs.

By luck, the errors within the lost output may be very similar to the errors about the lost output. But in general the system logs have no useful information about why a cron job failed.

Unless you have a valid MAILTO= line in your crontab, cron will be trying to mail to <root>, which msmtp may not be able to handle even when the network is up. You may be better to redirect your job output to a file like >/tmp/cron.log 2>&1

You should not need root privilege to take a picture or send an email.

Candyjet
Posts: 66
Joined: Sun Jan 10, 2016 3:45 pm

Re: MSMTPRC default account settings

Tue Mar 28, 2023 3:00 pm

Thanks to both of you. A team effort has paid off in this instance.

Thanks Scruss for the 'wait for network' raspi-config tip. It identified the problem, though having selected that option, I still got a network not available message. I then stuck a sleep(60) line in, between taking the photo and emailing it, which seemed to nail the problem, without quite knowing why.

Then on to jojopi who's cron.log tip helped monitor the problem.

All sorted.

One other thing I have learned from this, is not 'Google is your friend'. It can also lead you right up the garden path, if you follow duff instructions from tinternet.

Cheers,

CJ

Return to “Troubleshooting”