Sending Mail & Geo Tagging Using Python
Sending Mail & Geo Tagging Using Python
& Geocoding
using python
Sending basic email
#native library in Python to send emails
import smtplib
#To create an SMTP object, each object is used for connection with
one server
server = smtplib.SMTP('smtp.gmail.com', 587)
server.starttls()
#security function, needed to connect to the Gmail server
server.login("YOUR EMAIL ADDRESS", "YOUR PASSWORD")
#Create the MIMEMultipart message object and load it with appropriate headers for From, To,
and Subject fields
msg = MIMEMultipart()
msg['From'] = fromaddr
msg['To'] = toaddr
msg['Subject'] = "SUBJECT OF THE MAIL"
msg['From'] = fromaddr
msg['To'] = toaddr
msg['Subject'] = "SUBJECT OF THE EMAIL"
msg.attach(MIMEText(body, 'plain'))
filename = "Notepad.txt"
attachment = open("C:\\Users\\SAI\\Desktop\\Notepad.txt","rb")
msg.attach(part)
Ex:
import geocoder
g = geocoder.google('Mountain View, CA')
print(g.latlng)
Output:
[37.3860517, -122.0838511]
Try:
g.osm
g.json
Reverse Geocoding using
python
import geocoder
g = geocoder.google([45.15, -75.14],
method='reverse')
print(g.city)
Output:
Berwick
Try:
g.state
g.state_long
g.country
g.country_long