Code Monkey home page Code Monkey logo

daily_email_project's Introduction

Daily email

Email contains

  • Today's weather and temperature
  • Joke of the day
  • Quote of the day
  • more?

Local project setup

  • Create a virtual environment with Python 3.8 and activate it
  • pip install -r requirements.txt
  • Create a copy of .env-sample and rename it to .env
  • Update values in .env for your email/password and coordinates
    • Put data in this file that you don't want to make public. Don't commit it to git.

Run the code

python daily_email/main.py {your_name}

Python Anywhere setup

Get the code

  1. From the homepage, go to Consoles and open a new Bash Console
  2. In the terminal, clone this repository git clone <repo_url>
  3. Navigate into the project folder cd daily_email_project

Install project requirements

  1. Install the requirements pip3.8 install --user -r requirements.txt
    • You must use the --user flag to install your own modules in PythonAnywhere

Set your secret variables

  1. From the homepage, go to the Files
  2. Open up the daily_email_project directory
  3. Open the .env-sample file
  4. Click Save as... and rename to .env
  5. Fill in your info and save

Create a scheduled task

  1. From the homepage, go to Tasks
  2. Create a new task with details:
    • Frequency: Daily
    • Time: Current server time + 1 minute
    • Command: python3.8 /home/<your_username>/daily_email_project/daily_email/main.py
    • Description: Daily email
  3. Save the task
  4. See the console logs for print messages or errors
  5. Once errors are resolved, set the task time for the morning and you're done!

Troubleshooting

SMTPAuthenticationError

smtplib.SMTPAuthenticationError:
Please log in via your web browser and then try again.
Learn more at https://support.google.com/mail/answer/78754

You must create a Google app password to log into your Gmail account.

  1. Turn on 2-Step verification
  2. Create an app password
  3. Use that password as the GMAIL_PASSWORD in your .env file

ProxyError or OSError

requests.exceptions.ProxyError: HTTPSConnectionPool(host='api.jokes.one', port=443):
Max retries exceeded with url: /jod 
(Caused by ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 403 Forbidden')))

The API you are requesting isn't on Python Anywhere's list of allowed URLs.

Read more about their policy.

To request that your API be added to the list of allowed URLs:

  1. Send a message through the "Send feedback" button in the header
  2. Send an email to [email protected]

Make sure to include:

  • a link to the API documentation. Particularly to documentation that states the domain where the API is published.
  • the domain or domains (including subdomains) that the API is served from.

You will probably want to wrap each API call in a try block so that successful calls get sent in an email and unsuccessful ones get printed to the console.

License

This project has no license. See the LICENSE file for more details.

You can choose a license from https://choosealicense.com/. Replace contents of LICENSE with the license content.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.