Spaces:
Sleeping
Sleeping
Commit
·
0e7be9f
1
Parent(s):
c9288f3
Update app.py
Browse files
app.py
CHANGED
|
@@ -133,6 +133,50 @@ def send_yagmail(email,msg,stdate):
|
|
| 133 |
)
|
| 134 |
st.success("Yagmail sent successfully!")
|
| 135 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 136 |
def main():
|
| 137 |
|
| 138 |
st.set_page_config(
|
|
@@ -188,10 +232,13 @@ def main():
|
|
| 188 |
#st.success("Insight generated!")
|
| 189 |
st.markdown(prediction)
|
| 190 |
#st.text(prediction)
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
email=
|
| 194 |
-
|
|
|
|
|
|
|
|
|
|
| 195 |
|
| 196 |
|
| 197 |
if __name__ == '__main__':
|
|
|
|
| 133 |
)
|
| 134 |
st.success("Yagmail sent successfully!")
|
| 135 |
|
| 136 |
+
def send_brevomail(email,msg,stdate):
|
| 137 |
+
|
| 138 |
+
url = 'https://api.brevo.com/v3/smtp/email'
|
| 139 |
+
headers = {
|
| 140 |
+
'accept': 'application/json',
|
| 141 |
+
'api-key': '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',
|
| 142 |
+
'content-type': 'application/json'
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
+
sender_email = "einsteingptai@gmail.com"
|
| 146 |
+
receiver_email = email
|
| 147 |
+
subject = "Your Horoscope for " + stdate
|
| 148 |
+
body = msg
|
| 149 |
+
|
| 150 |
+
data = {
|
| 151 |
+
"sender": {
|
| 152 |
+
"name": "Einstein AI",
|
| 153 |
+
"email": sender_email
|
| 154 |
+
},
|
| 155 |
+
"to": [
|
| 156 |
+
{
|
| 157 |
+
"email": receiver_email
|
| 158 |
+
}
|
| 159 |
+
],
|
| 160 |
+
"subject": subject,
|
| 161 |
+
"htmlContent": body
|
| 162 |
+
}
|
| 163 |
+
|
| 164 |
+
try:
|
| 165 |
+
response = requests.post(url, headers=headers, data=json.dumps(data))
|
| 166 |
+
if response.status_code == 200:
|
| 167 |
+
st.success("Email sent successfully!")
|
| 168 |
+
print(response.text)
|
| 169 |
+
else:
|
| 170 |
+
st.error(f"Error {response.status_code}: {response.text}")
|
| 171 |
+
except requests.exceptions.HTTPError as errh:
|
| 172 |
+
st.error(f"HTTP Error: {errh}")
|
| 173 |
+
except requests.exceptions.ConnectionError as errc:
|
| 174 |
+
st.error(f"Error Connecting: {errc}")
|
| 175 |
+
except requests.exceptions.Timeout as errt:
|
| 176 |
+
st.error(f"Timeout Error: {errt}")
|
| 177 |
+
except requests.exceptions.RequestException as err:
|
| 178 |
+
st.error(f"An unexpected error occurred: {err}")
|
| 179 |
+
|
| 180 |
def main():
|
| 181 |
|
| 182 |
st.set_page_config(
|
|
|
|
| 232 |
#st.success("Insight generated!")
|
| 233 |
st.markdown(prediction)
|
| 234 |
#st.text(prediction)
|
| 235 |
+
|
| 236 |
+
|
| 237 |
+
email = st.text_input("Enter email address", "")
|
| 238 |
+
|
| 239 |
+
if st.button("Send Email"):
|
| 240 |
+
remail=email.strip()
|
| 241 |
+
send_brevomail(remail,prediction,strtime)
|
| 242 |
|
| 243 |
|
| 244 |
if __name__ == '__main__':
|