I was trying to troubleshoot why my Raspberry Pi isn't sending emails with ssmtp / mail-utils, and so I opened up my gmail account that I use for the Pi. To my surprise, there were 15k unread emails where it had tried to send an email to the email address "pi@pi_name", which was obviously rejected (was trying to send to email@example.com). These emails/rejections occur about once every couple of minutes. The rejections are one thing (I must just have the configuration wrong), but it puzzles me what's going on here. In my
crontab -u pi -l I have the following (root's crontab is empty):
30 8 * * * python /.../text.py * * * * * python /.../record.py
text.py is supposed to send me reminders at 8:30 every day, and record.py is supposed to run every minute to record some audio.
In the emails that are being sent, the body of the email is the output from record.py (recorded audio details). My intuition is that the emails are related to the cron job that runs every minute (even though the emails are approximately once every 3 minutes), but nowhere in record.py is there any mention to sending email; it just writes to a MySQL db. text.py sends emails using the command
echo “body” | mail -s “subject” firstname.lastname@example.org
I'm perplexed as to what's going on here. I have no idea where the emails are being sent from, and furthermore, everything was working as intended in January of this year (I put my Pi into storage when I went abroad for a few months), and I haven't made any changes to it.
Also weird and maybe related is that when I enter the command python text.py, it randomly works (maybe a 5% chance?) and texts me, otherwise it errors with
send-mail: Cannot open smtp.gmail.com:587. I'm not sure under what circumstances it succeeds.