The screenshot of my code. How do I resolve this?
The error screenshot
Head to this thread. All your possible solutions, you will find there.
Remove the the below line from your code
response_text = json.loads(response.text)
print("Response received from Mailgun is: " + str(response_text['message']))
and directly print the response without doing json.loads()
print ("Mailgun response is " + response.text)
Another method - Put this on the email part
response_email = mailer.send_email (“Alert”, " current temperature sensor value is: "+ str(data[‘value’])
response_text = json.loads( response_email .text)
print("Response received from Mailgun is: " + str(response_text[‘message’]))
I’m not receiving the mail. I followed the directions you said in the thread you mentioned but still not getting emails
while True:
print (“Reading sensor value”)
response = mybolt.analogRead(‘A0’)
data = json.loads(response)
print ("Sensor value is: " + str(data[‘value’]))
try:
sensor_value = int(data[‘value’])
if sensor_value > maximum_limit or sensor_value < minimum_limit:
print(“Making request to Mailgun to send an email”)
response = mailer.send_email(“Alert”, "The Current temperature sensor value is " +str(sensor_value))
print ("Mailgun response is " + response.text)
except Exception as e:
print (“Error occured: Below are the details”)
print (e)
time.sleep(10)
CHANGE YOUR CODE WITH THIS AND YOUR ISSUE WILL BE SOLVED
this is my code but it’s still not working
response = mailer.send_email(“Alert”, "The Current temperature sensor value is " +str(sensor_value))
print ("Mailgun response is " + response.text)
replace the above line with yours
this will directly print the response without doing json.loads()
Your code is working fine without any error right? Tell me about that first.
Yes the code is working
Ok great ! Have you verified your recipient email on mailgun.com?
I want you to stick with me here, I will help you through it as quickly as possible.
Yes I have verified my email
Recipient Email. Not asking about mailgun account. Go through this post, and check if you have VERIFIED your recipient mail.
Yes I have verified the email like that
Great. Check your spam/junk folder of your email.
Spam is empty and no new email
Does your mailgun dashboard look something like this?
0/0 delivererd ?
yes it looks like that
Run the code, fulfill the condition and send a screenshot here.