Skip to content

ariannedee/daily_email_project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 info@pythonanywhere.com

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.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages