Mailgun Showing Error
To resolve this issue, first, check your API request and ensure that all required parameters are included and formatted correctly. Make sure that the payload is properly formatted as JSON and does not contain any extra data that is not recognized by the server.
Let us know if your query resolved
Can you share the code so we can assist you.
**Bellow is my code**
from boltiot import Email, Bolt
import json, time
mybolt Bolt (email_conf.API_KEY, email_conf.DEVICE_ID)
mailer Email(email_conf.MAILGUN_API_KEY, email_conf. SANDBOX_URL, email_conf.SENDER_EMAIL, email_conf.RECIPIENT_EMAIL)
print (“Reading Sensor Value”)
data= json. loads (response)
print ("Sensor value is "+str(data[‘value’]))
if sensor_value>max or sensor_value <min:
print(“Making request to Mailgun to send email”)
response-mailer.send_email(“Alert”, "The current temperature is "+str(temperature))
response_text = json. loads (response.text)
print ("Response recived from Mailgun is "+str(response_text [‘message’]))
except Exception as e:
print(“Error occured bellow are the detailes”)
The code is encountering multiple errors, some of which are:
Incorrect usage of quotes: The quotes used in the code are not standard quotes, which are causing a syntax error. Use either single quotes (’ ') or double quotes (" ") instead of the quotes used in the code.
Incorrect use of equals sign: The equals sign = is being used instead of the minus sign - in the following line: response-mailer.send_email(“Alert”, "The current temperature is "+str(temperature)).
Incorrect class instantiation: The class instantiation for Bolt and Email is missing the = sign. Use mybolt = Bolt(email_conf.API_KEY, email_conf.DEVICE_ID) and mailer = Email(email_conf.MAILGUN_API_KEY, email_conf.SANDBOX_URL, email_conf.SENDER_EMAIL, email_conf.RECIPIENT_EMAIL).
Incorrect variable names: The variable name min shadows the built-in function min(), which is not recommended. Rename the variable to a more meaningful name, like min_value.
Incorrect mathematical operation:
The multiplication operator * is being represented as the letter x, causing a syntax error. Change 100xsensor_value to 100 * sensor_value.
I changed accordingly but problem is not solved