Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug]: Make contact form working #26

Closed
3 tasks done
ashutoshkrris opened this issue Oct 21, 2021 · 48 comments · Fixed by #39 or BidyutBikashBharali/EazyLoader#1
Closed
3 tasks done

[bug]: Make contact form working #26

ashutoshkrris opened this issue Oct 21, 2021 · 48 comments · Fixed by #39 or BidyutBikashBharali/EazyLoader#1
Assignees
Labels
backend bug Something isn't working enhancement New feature or request good first issue Good for newcomers hacktoberfest Issue:Assigned

Comments

@ashutoshkrris
Copy link
Owner

Is there an existing issue for this?

  • I have searched the existing issues.

Describe the feature.

The contact form(on the homepage) is not working as of now.

Problem/Motivation.

If somebody faces any issue, they can report using the contact form.

Possible Solution/Pitch.

Instead of saving the contact form data in any database, we can use Flask-Mail to mail the contact form data to the admin email.
Make sure you use HTML templates for the email.

Anything else?

This is a beginner-friendly backend issue.

Hacktoberfest

  • Yeah

Code of Conduct

  • I agree to follow this project's Code of Conduct
@github-actions github-actions bot added backend bug Something isn't working enhancement New feature or request good first issue Good for newcomers hacktoberfest Up-For-Grab labels Oct 21, 2021
@ashutoshkrris ashutoshkrris added bug Something isn't working and removed bug Something isn't working labels Oct 21, 2021
@ashutoshkrris ashutoshkrris changed the title [feature request]: Make contact form working [bug]: Make contact form working Oct 21, 2021
@ashutoshkrris ashutoshkrris removed the enhancement New feature or request label Oct 21, 2021
@github-actions github-actions bot added the enhancement New feature or request label Oct 21, 2021
@TimeglitchD
Copy link

Can I have a shot at this one?

@ashutoshkrris
Copy link
Owner Author

Go ahead!
Assigning it to you @TimeglitchD

@ashutoshkrris
Copy link
Owner Author

Any updates? @TimeglitchD

@TimeglitchD
Copy link

I can't seem to get the setup working, so it's probably not fair to keep it assigned to me, feel free to assign someone else. Sorry for the inconvenience!

@ashutoshkrris
Copy link
Owner Author

@TimeglitchD
The contributing guidelines have been updated. If you wish, you can check out that.
Also, would you let me know where are you stuck?

@BidyutBikashBharali
Copy link
Contributor

Hey, I'm interested to solve this bug and want to contribute to this amazing project on this Hacktoberfest 2021

@ashutoshkrris
Copy link
Owner Author

Hey, I'm interested to solve this bug and want to contribute to this amazing project on this Hacktoberfest 2021

Alright, assigning it to you!

@BidyutBikashBharali
Copy link
Contributor

Before stating development , would you like to help me by answering my following queries ? ->

  1. In index.html, line: 96 ,

    , what does this( data-sb-form-api-token="API_TOKEN" ) do?

  2. I couldn't find any residing python method/class to handle the contact form data.
    please tell me the file name and line no if there exist such python method/class, otherwise i will add new method to handle form data.

  3. Do you want to store contact form data in database or want a functionality to send these form data to admin's email.

  4. you are hosting this website on heroku, so if you want to add me mail service for sending form data, using flask-mail might not work in production for heroku.
    But Sendgrid email or AWS SES will definately allow to send mail from any type of email server on heroku. And Sendgrid will be quick solution for this.

@ashutoshkrris
Copy link
Owner Author

  1. The data-sb-form-api-token="API_TOKEN" has nothing to do with the form now, and it can be removed. It was there in Bootstrap template.

  2. There is no method as of now, and you can create one in the core/routes.py file.

  3. Since, we aren't using Database for now. It would be better to send email to the Admin Email. Add an environment variable such as ADMIN_EMAIL

  4. Flask-Mail works fine on heroku too. You can go ahead with that.

Also, the email that the admin will receive should be a HTML template.

@ThisIsBBBGithubAc

@BidyutBikashBharali
Copy link
Contributor

Hi, i have one more query regarding Hacktoberfest 2021. I saw list of company's repository and individual's repository in Hacktoberfest official website. So to win a swag , do i need to do something else ? and who will provide the Hacktoberfest Swag gift if someone contributed to some individual's repository but not in the participating company's repository?

@ashutoshkrris
Copy link
Owner Author

It is not compulsory to contribute in the participating company's respository.
You can contribute to any respository that has hacktoberfest label. And yes, contributing to this respository will count towards your Hacktoberfest Contribution

Once you complete 4 successful PRs, you'll receive mail from Hacktoberfest where you need to order your TShirt

@BidyutBikashBharali
Copy link
Contributor

BidyutBikashBharali commented Oct 26, 2021 via email

@BidyutBikashBharali
Copy link
Contributor

Since, I'm fixing one bug , how to do 4 pull requests. I'm little confused with this thing! How to do this? Do i have to commit and PR this development into 4 different parts of codes or what?

@ashutoshkrris
Copy link
Owner Author

You need to resolve four issues and create four different PRs. The repository can be one or more than one, doesn't matter. But it should have hacktoberfest label on it.

@ashutoshkrris
Copy link
Owner Author

Also, share what changes have you done so far?
May be there would some minor typos

@BidyutBikashBharali
Copy link
Contributor

Hi, please check: https://github.com/ThisIsBBBGithubAc/EazyLoader.git

@ashutoshkrris
Copy link
Owner Author

Hi, please check: https://github.com/ThisIsBBBGithubAc/EazyLoader.git

Did you set ADMIN_EMAIL environment variable in .env file? Also whenever you modify this file, make sure you deactivate the virtual environment and activate it again to avoid errors.

@BidyutBikashBharali
Copy link
Contributor

Yeah, i used ADMIN_EMAIL in .env and other configurations related to flask_mail in config.py and also reactivated the virtual environment.....but still getting the same error.

@ashutoshkrris
Copy link
Owner Author

ashutoshkrris commented Oct 27, 2021

In the config.py file, did you set these configurations in the Config class?

MAIL_SERVER = 'smtp.gmail.com'
MAIL_PORT = 587
MAIL_USE_TLS = True
MAIL_USERNAME = config("EMAIL_ADDRESS")
MAIL_PASSWORD = config("EMAIL_PASSWORD")
MAIL_DEBUG = True

I suppose, you haven't added these. @ThisIsBBBGithubAc

Note: EMAIL_ADDRESS and EMAIL_PASSWORD should be added in the .env file.

@BidyutBikashBharali
Copy link
Contributor

BidyutBikashBharali commented Oct 27, 2021

I used these:

#EMAIL SETTINGS MAIL_SERVER = 'smtp.gmail.com', MAIL_PORT = 465, MAIL_USE_SSL = True, MAIL_USE_TLS = False, MAIL_USERNAME = 'adminmail@gmail.com', MAIL_PASSWORD = 'password'

@ashutoshkrris
Copy link
Owner Author

Try replacing with the one that I sent you.
Also, set the MAIL_USERNAME and MAIL_PASSWORD for a working Gmail account.
You might need to switch on Less Secure Apps Access in your Gmail Settings

@BidyutBikashBharali
Copy link
Contributor

Yes, i have tried all these ......but getting the same error

@ashutoshkrris
Copy link
Owner Author

Yes, i have tried all these ......but getting the same error

Can you update your branch with the latest changes so that I can test it.

@ashutoshkrris
Copy link
Owner Author

Well, I tried with the changes you have made till now.
There was no modification in the config.py file, so I added this:

class Config(object):
    SECRET_KEY = config('SECRET_KEY') or 'guess-me'
    DEBUG = False
    TESTING = False
    CSRF_ENABLED = True
    MAIL_SERVER = 'smtp.gmail.com'
    MAIL_PORT = 587
    MAIL_USE_TLS = True
    MAIL_USERNAME = config("EMAIL_ADDRESS")
    MAIL_PASSWORD = config("EMAIL_PASSWORD")
    MAIL_DEBUG = True

And it worked fine for me.

@BidyutBikashBharali
Copy link
Contributor

BidyutBikashBharali commented Oct 27, 2021

Yeah, my previous codes have started working now. What i was doing wrong is i was using commas(,) for each line in config.py file like this:

MAIL_SERVER = 'smtp.gmail.com', MAIL_PORT = 465, MAIL_USE_SSL = True, MAIL_USE_TLS = False

It started working after i remove these commas. Thank you

@ashutoshkrris
Copy link
Owner Author

Great to hear that!
Also, the email should be an HTML template, so work accordingly

@BidyutBikashBharali
Copy link
Contributor

Sure

@BidyutBikashBharali
Copy link
Contributor

logo_for_email_template

Hi, Please download this image( i cropped it from logo.png) and rename it as "logo_for_email_template.png". Since this image is in local directory it will not be loaded in email . So host it somewhere and send me the url. You can use google drive (quick solution)

@ashutoshkrris
Copy link
Owner Author

Wait, I'll send you the URL

@ashutoshkrris
Copy link
Owner Author

@ThisIsBBBGithubAc
Image URL : https://i.imgur.com/971aIwi.png

@BidyutBikashBharali
Copy link
Contributor

image through https://i.imgur.com/971aIwi.png was not loaded, since this link is returning the image with html page

@ashutoshkrris
Copy link
Owner Author

@BidyutBikashBharali
Copy link
Contributor

Okay, Now it's working

@BidyutBikashBharali
Copy link
Contributor

Capture

Please suggest if any change needed!

@ashutoshkrris
Copy link
Owner Author

Amazing!!!

@BidyutBikashBharali
Copy link
Contributor

After form Submission Success, do you want this to show :

Form submission successful!
To activate this form, sign up at
https://startbootstrap.com/solution/contact-forms (previously written html)

or

Form submitted successfully! (flash message)

@ashutoshkrris
Copy link
Owner Author

Just flash the message and redirect to the contact form section again.
For showing the message in the template, you can use the includes/alerts.html

@BidyutBikashBharali
Copy link
Contributor

Hi, please check: https://github.com/ThisIsBBBGithubAc/EazyLoader , recently updated, bug fixed.

@ashutoshkrris
Copy link
Owner Author

Looks good to me!
Take the latest pull from this repo and create PR

@BidyutBikashBharali
Copy link
Contributor

i didn't understand this "Take the latest pull from this repo".....why is this necessary ?

@ashutoshkrris
Copy link
Owner Author

To avoid merge conflicts

Go to this respository's home page and you'll find an option to fetch upstream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend bug Something isn't working enhancement New feature or request good first issue Good for newcomers hacktoberfest Issue:Assigned
Projects
None yet
3 participants