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