KrittIT Blog Setup Part 4

KrittIT Blog Setup Part 4

Previously

In the last part we configured and created your first blog post. Only a step or two left till you can deploy your site.

Contact Form Configuration

In this section we will go over how to properly set up the environment variables for the contact form. If you chose not to enable the contact form then you can skip the post and head to the next one. Once the variables are set it will make it so that when someone presses the submit button on the contact page, you will get an email with their message and info. We will go through each variable one by one.

Security - Throughout the rest of this post we will be referring to the .env file. This file is meant to show you the variable names and approximations of their corresponding values. I highly recommend you don't put your actual credentials in this file. Instead, I recommend you write this information down somewhere handy, so it is available when we deploy your blog. When deploying there will be a place to input these variables in a secure location with your hosting provider. If you are the only one that will have access to this repository and just are not that worried about then filling out the .env file properly will get the contact form working as well.

.env File

In your projects root directory you should see a file called .env. If you don't see it then you will need to enable show hidden files in your OS


TO_EMAIL_ADDRESS

Here you will put the email address you want to receive the email on.

TO_EMAIL_ADDRESS=[email protected]


FROM_EMAIL_ADDRESS

Here you will put the email address that will be sending the email. This can be the same value as the TO_EMAIL_ADDRESS variable.

FROM_EMAIL_ADDRESS=[email protected]


SMTP_ADDRESS

This one may take a bit of work depending on who your email provider is. Search for 'your email provider' smtp settings. In the settings that come up you should see a smtp server address. It will look like smtp.something.com. Make sure it is the outgoing server settings address. You will put the server address they provided as the value of this variable.

SMTP_ADDRESS=smtp.example.com


SMTP_PORT

Within the information you found by searching for the smtp settings should be your port number. Make sure you are looking at the outgoing settings and put the number they give you as the value for this variable.

SMTP_PORT=587


EMAIL_SECURE

Still within the information you found when searching for your smtp settings, you should see something referring to ssl. If your outgoing server uses ssl put true as the value if not put false. Sometimes it will be dependent on what port you are using weather or not ssl is enabled so be sure to make sure that the value you put here corresponds with the port you imputed above.

EMAIL_SECURE=true


EMAIL_USERNAME

Here you will put your username for the sending email address as the value. Be aware this maybe your whole email address instead of just the part before the @ symbol.

EMAIL_USERNAME=[email protected]


EMAIL_PASSWORD

Here you will put your password for the sending email address as the value.

EMAIL_PASSWORD=example


<---- Previous ----- Next ---->