Search code examples
emailflaskserverweb-deploymentweb-hosting

How to recieve email from Contact Us from written with Flask


I just created a Contact Us form using Flask. The code seems to work correclty as explained in many tutorials like this one: link.

The reason why it all works it is because at the beginning of the app file I need to insert the username and password of the person who is sending the mail (in this case it's me) through the form:

mail = Mail()
app.config["MAIL_SERVER"] = "smtp.gmail.com"
app.config["MAIL_PORT"] = 465
app.config["MAIL_USE_SSL"] = True
app.config["MAIL_USERNAME"] = '[email protected]'
app.config["MAIL_PASSWORD"] = 'my_personal_password'
mail.init_app(app)

However once my website will be hosted online in some server, whoever wants to contact me trhough the form will just have the option to insert his email in the form and of course no password. Here it is what it looks like:

                               enter image description here

Would you be able to explain how this situation is handle once I host the website in some server? Is there something wrong with my logic?


Solution

  • You can do 2 things here

    1. You need to store the details in the database and make an admin panel to view the details from the database
    2. Create a fake Gmail and let that Gmail send you the users name, email subject, and message

    I personally prefer the 1st option