The Problem
A few days ago I discovered that the battery powered, ESP8266 based temperature monitor in one of my greenhouses had stopped transmitting data ti my local web server. When I investigated further, I found that the battery was flat.
This was a surprise, as I hadn't received any emails warning me that the battery voltage was low. The method I use has worked totally reliably since I first implemented it almost 2 years ago, as described here:
After switching on the battery charger, I returned to my current project, intending to look further into the email problem when I had more time.
Later the same day, I received an email from SMTP2GO, who provide the email forwarding service, as described in my earlier blog. The essence of their message was that the emails from my temperature monitor were bouncing because I was sending from a mymail.com address and that mymail.com has an SPF record that prohibits sending from servers outside their own network. Their advice was to use a genuine email address either from live.com or outlook.com, but to avoid AOL and Yahoo addresses.
I was a bit confused by all this, because the system had been working perfectly for the past 2 years, and the last time emails had been successfully sent was only 2 weeks ago (the typical life of the battery). I exchanged a few emails with SMTP2GO support team in order to clarify the situation and here is the (simple) solution:
The Solution
In the code snippets of my original post, I gave the following lines of code:
client.println(F("MAIL From: yrmail@gmail.com")); // Not a real address
client.println(F("From: yrmail@gmail.com"));
Although this worked at the time, for some reason which I can't remember, I switched to an imaginary address using mymail.com.
In order to comply with the advice from SMTP2GO, I registered a suitable address with outlook.com.
I then modified a test sketch, which just sends a test email, to use the new address. This worked, so I emailed SMTP2GO to let them know.
I received a fairy quick reply to tell me that everything was now OK.
Phew