Why does the mailing not work perfectly? What's wrong in this implementation?

15 views
Skip to first unread message

Jacob Devin

unread,
Mar 27, 2016, 3:04:08 AM3/27/16
to web2py-users
inside view I have:

 <script type="text/javascript" src="http://www.google.com/jsapi?key=<YOUR_GOOGLE_API_KEY>"></script>
    <script type="text/javascript">
       if(google.loader.ClientLocation)
        {
            visitor_lat = google.loader.ClientLocation.latitude;
            visitor_lon = google.loader.ClientLocation.longitude;
            visitor_city = google.loader.ClientLocation.address.city;
            visitor_region = google.loader.ClientLocation.address.region;
            visitor_country = google.loader.ClientLocation.address.country;
            visitor_countrycode = google.loader.ClientLocation.address.country_code;
           ajax('{{=URL('default', 'location')}}' + '?lat=' + visitor_lat + '&lon=' + visitor_lon + '&city=' + visitor_city + '&region=' + visitor_region + '&country=' + visitor_country + '&countrycode=' + visitor_countrycode, [], ':eval');
        }
      </script>


controller function location is as:

def location():
    lat=request.vars.lat
    lon=request.vars.lon
    city=request.vars.city
    region=request.vars.region
    country=request.vars.country
    countrycode=request.vars.countrycode
    device=str(request.user_agent)
    start=device.find("HTTP_USER_AGENT") + 18
    end=device.find("HTTP_CONNECTION") - 3
    device=device[start:end]
    date_time=request.utcnow+datetime.timedelta(0,19800)
    date_time=str(date_time)
    db.visitors.insert(latitude=lat,longitude=lon,city=city,region=region,country=country,countrycode=countrycode,device=device,date_time=date_time)
    mail.send('mym...@gmail.com',
                  'Someone just checked your ePortfolio',
                  message='<html><style></style><body><h1 style="background-color:rgb(236, 255, 136);display:inline" >Hola Amigos Mr. Jacob!</h1><br><div style="width:500px;height:100px;background-color:lightblue;opacity:0.8"><h3>You have a new visitor</h3><h3>From ip address: %s</h3><h3>Latitude: %s and longitude: %s</h3><h3>Address:  %s, %s, %s, %s </h3><h3>and device model: %s</h3> </div></body></html>' %(str(request.client), str(lat), str(lon), str(city), str(region), str(country), str(countrycode), device ))


I do get emails but a very few times!
Reply all
Reply to author
Forward
0 new messages