Using Environment Specific Settings4:18 with Alena Holligan
Moving credentials is only one part of making your application adaptable. The settings for your application may also need to change based upon the environment.
For Setting up SMTP, check out this video and the corresponding notes.
Environment Variables for Google SMTP
Only difference for yahoo is
SMTP_DEBUG=2 SMTP_HOST="smtp.gmail.com" SMTP_PORT=587 SMTP_SECURE="tls" SMTP_AUTH=true SMTP_USERNAME=most_likely_your_email SMTP_PASSWORD=app_password SMTP_FROM=most_likely_your_email MAILTO_EMAIL=most_likely_your_email MAILTO_NAME=any_name
For details on setting up your own SMTP with Google or 0:00 other providers please check the notes associated with this video. 0:04 What we are going to be doing for 0:08 this project is moving the SMTP settings into environment variables. 0:10 You'll need an app password, so go ahead and 0:14 get that set up if you haven't already. 0:16 Don't worry, I'll be here when you're done. 0:18 If we are always using the same SMTP provider, 0:21 we'd only need to switch out the username and password. 0:24 But what if we have different providers for different environments? 0:27 Let's switch out all of our SMTP setting starting with debug. 0:31 Debug is for sure something that we want to change based on environment. 0:35 In our dev environment, we want all the details we can get, but for 0:39 prod we'll turn them completely off. 0:44 Let's update our .ENV file first. 0:46 SMTP_DEBUG=2. 0:56 SMTP_HOST="smtp.gmail.com" 1:01 SMTP_PORT, =587. 1:11 SMTP_SECURE="tls". 1:19 SMTP_AUTH=true. 1:26 And we'll want our SMTP_USERNAME and PASSWORD. 1:34 Make sure you also add SMTP_FROM. 1:40 For Gmail this needs to be set as our same Gmail email address. 1:47 Let's also switch out the MAILTO_EMAIL and NAME. 1:56 Once again, saving the file. 2:22 Now we can go back and switch out all the hard-coded information. 2:30 Getenv. 2:38 Whoops. 2:42 Copy this. 2:44 Oops, SMTP_. 2:47 We'll copy all of that. 2:50 And this will be DEBUG. 2:54 HOST. 3:01 PORT. 3:05 SECURE. 3:10 AUTH. 3:15 The USERNAME, And PASSWORD. 3:23 We'll also change SMTP_FROM. 3:38 And our mailtos. 3:43 MAILTO_EMAIL and, MAILTO_NAME. 3:49 Let's give this a try in the browser again to make sure things still work. 3:56 Looks good. 4:12 Now that we've secured our credentials, we're ready to change the data source for 4:13 the quotes. 4:17
You need to sign up for Treehouse in order to download course files.Sign up