Added Rain Alert Mail Sender#997
Conversation
| MY_MAIL= ENTER_YOUR_MAIL | ||
| MY_PASSWORD= ENTER_YOUR_PASSWORD | ||
| RECIEVER_MAIL = RECIEVER_MAIL |
There was a problem hiding this comment.
Get these inputs from user using input function
| LAT = 22.572645 | ||
| LONG = 88.363892 |
There was a problem hiding this comment.
What are these coordinates for? If you're using them for location then get the location from the user and then use https://nominatim.openstreetmap.org/search/ to get the exact coordinates of the location
| LAT = 22.572645 | ||
| LONG = 88.363892 | ||
|
|
||
| API_KEY = API |
|
@kaustubhgupta please check |
| RECIEVER_MAIL = input('Send mail to (mail id): ') | ||
| CITY = input('Enter your City: ') | ||
|
|
||
| API_KEY = input('Type in API from OpenWeather: ') |
There was a problem hiding this comment.
| API_KEY = input('Type in API from OpenWeather: ') | |
| API_KEY = input('Type in API key from OpenWeather: ') |
| if (bring_umbrella == True): | ||
| with SMTP("smtp.gmail.com") as connection: | ||
| connection.starttls() | ||
| connection.login(user=MY_MAIL, password=MY_PASSWORD) | ||
| connection.sendmail(from_addr=MY_MAIL, to_addrs=RECIEVER_MAIL, | ||
| msg=f"Subject: Rain Rain \n\nIt's going to rain today. Bring Umbrella ") | ||
| print('Mail Sent') | ||
| else: | ||
| with SMTP("smtp.gmail.com") as connection: | ||
| connection.starttls() | ||
| connection.login(user=MY_MAIL, password=MY_PASSWORD) | ||
| connection.sendmail(from_addr=MY_MAIL, to_addrs='shubhrijana@gmail.com', | ||
| msg=f"Subject: Sunny Day\n\nMay be a sunny day. Carry sunglasses. ") | ||
| print('Mail Sent') |
There was a problem hiding this comment.
Instead of duplicating the code for making a Gmail connection, the only thing that changes in if-else is the msg content. So, in if-else statements, just modify the message variable and then sent the message. This is what I mean to say:
if umbrella:
msg = Subject: Rain Rain \n\nIt's going to rain today. Bring Umbrella
else:
msg = Subject: Sunny Day\n\nMay be a sunny day. Carry sunglasses.
with SMTP("smtp.gmail.com") as connection:
connection.sendmail(from_addr=MY_MAIL, to_addrs=RECIEVER_MAIL, msg=msg)
|
@kaustubhgupta please check |
| MY_MAIL= input('Enter your mail id: ') | ||
| MY_PASSWORD= input('Enter password: ') | ||
| RECIEVER_MAIL = input('Send mail to (mail id): ') | ||
| #get latitude longitude from "https://www.latlong.net/" |
| import requests | ||
| from smtplib import SMTP | ||
|
|
||
| #turn off certain security criteria in sender mail address |
There was a problem hiding this comment.
What type of security criteria? Kindly mention them as doc string
antrikshmisri
left a comment
There was a problem hiding this comment.
Instead of taking inputs for every variable, you can take the values from a .env file.
Please Check |
kaustubhgupta
left a comment
There was a problem hiding this comment.
@Shubhrima Add the requirements.txt file and update the PR template with project metadata. Look at this PR for reference: #1002
please check |
kaustubhgupta
left a comment
There was a problem hiding this comment.
PR template is wrongly filled. Please check other approved PRs for better understanding
Is it okay now? |
|
Due to inactivity this pull request has been marked as stale. |
Description
An application that checks the weather condition for the next 12 hours and sends a message to the registered mail address number as to whether one should carry a sunglass (if it is sunny) , or an umbrella (if it rains).
Fixes #993
Have you read the Contributing Guidelines on Pull Requests?
Type of change
Please delete options that are not relevant.
Checklist:
README.mdTemplate for README.mdProject Metadata
If there is no-file/nothing to fill the below fields with, then type: none
Example: If no requirements.txt needed/present, then type none in Requirments.
Category:
Title: Rain Alert Mail Sender
Folder: Rain Alert Mail Sender
Requirements: requirements.txt
Script: main.py
Arguments: none
Contributor: Shubhrima
Description: An application that alerts about the weather for the next 12 hours.