ashutoshkrris / EazyLoader

EazyLoader is Flask based web-application built to make downloading easy for you. Download videos and pictures from YouTube and Instagram in the best available quality. You can also download slides from SlideShare in PDF or PPTX format. In addition to that, you can calculate duration of YouTube Playlist at different speeds. You can also encrypt and decrypt your PDF files using this tool.
https://eazyloader.herokuapp.com
MIT License
65 stars 36 forks source link

[bug]: Make contact form working #26

Closed ashutoshkrris closed 2 years ago

ashutoshkrris commented 2 years ago

Is there an existing issue for this?

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

Code of Conduct

TimeglitchD commented 2 years ago

Can I have a shot at this one?

ashutoshkrris commented 2 years ago

Go ahead! Assigning it to you @TimeglitchD

ashutoshkrris commented 2 years ago

Any updates? @TimeglitchD

TimeglitchD commented 2 years ago

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 commented 2 years ago

@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 commented 2 years ago

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

ashutoshkrris commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago
  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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

Okay. Thank you

On Tue, 26 Oct 2021, 6:53 pm Ashutosh Krishna, @.***> wrote:

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

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ashutoshkrris/EazyLoader/issues/26#issuecomment-951934521, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQK5EYIFZXZPDT2KMUCDRQDUI2TTJANCNFSM5GNYSSAA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

BidyutBikashBharali commented 2 years ago

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 commented 2 years ago

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.

BidyutBikashBharali commented 2 years ago

Hi, I was getting some error yesterday while using Flask_Mail and more time might be needed to fix this error. So Can i continue with Other python library like SMTP, Sendgrid etc?

ashutoshkrris commented 2 years ago

Could you share the error log? May be we can resolve it @ThisIsBBBGithubAc

BidyutBikashBharali commented 2 years ago

this error was displayed: "TypeError: getaddrinfo() argument 1 must be string or None"

ashutoshkrris commented 2 years ago

Could you please share the entire error log, so that I can see the Line number and filename in which the error is occurring. Also, share the changes that you've made till now

BidyutBikashBharali commented 2 years ago

How to share the entire error log? please tell.

ashutoshkrris commented 2 years ago

You can just copy the last few lines from the terminal and paste it here as codeblock

BidyutBikashBharali commented 2 years ago

Traceback (most recent call last): File "/home/thisisbbb/OPEN_SOURCE_CONTRIBUTION/EazyLoader/env/lib/python3.8/site-packages/flask/app.py", line 2091, in __call__ return self.wsgi_app(environ, start_response) File "/home/thisisbbb/OPEN_SOURCE_CONTRIBUTION/EazyLoader/env/lib/python3.8/site-packages/flask/app.py", line 2076, in wsgi_app response = self.handle_exception(e) File "/home/thisisbbb/OPEN_SOURCE_CONTRIBUTION/EazyLoader/env/lib/python3.8/site-packages/flask/app.py", line 2073, in wsgi_app response = self.full_dispatch_request() File "/home/thisisbbb/OPEN_SOURCE_CONTRIBUTION/EazyLoader/env/lib/python3.8/site-packages/flask/app.py", line 1518, in full_dispatch_request rv = self.handle_user_exception(e) File "/home/thisisbbb/OPEN_SOURCE_CONTRIBUTION/EazyLoader/env/lib/python3.8/site-packages/flask/app.py", line 1516, in full_dispatch_request rv = self.dispatch_request() File "/home/thisisbbb/OPEN_SOURCE_CONTRIBUTION/EazyLoader/env/lib/python3.8/site-packages/flask/app.py", line 1502, in dispatch_request return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args) File "/home/thisisbbb/OPEN_SOURCE_CONTRIBUTION/EazyLoader/core/routes.py", line 29, in index mail.send(msg) File "/home/thisisbbb/OPEN_SOURCE_CONTRIBUTION/EazyLoader/env/lib/python3.8/site-packages/flask_mail.py", line 491, in send with self.connect() as connection: File "/home/thisisbbb/OPEN_SOURCE_CONTRIBUTION/EazyLoader/env/lib/python3.8/site-packages/flask_mail.py", line 144, in __enter__ self.host = self.configure_host() File "/home/thisisbbb/OPEN_SOURCE_CONTRIBUTION/EazyLoader/env/lib/python3.8/site-packages/flask_mail.py", line 156, in configure_host host = smtplib.SMTP_SSL(self.mail.server, self.mail.port) File "/usr/lib/python3.8/smtplib.py", line 1043, in __init__ SMTP.__init__(self, host, port, local_hostname, timeout, File "/usr/lib/python3.8/smtplib.py", line 255, in __init__ (code, msg) = self.connect(host, port) File "/usr/lib/python3.8/smtplib.py", line 339, in connect self.sock = self._get_socket(host, port, self.timeout) File "/usr/lib/python3.8/smtplib.py", line 1049, in _get_socket new_socket = socket.create_connection((host, port), timeout, File "/usr/lib/python3.8/socket.py", line 787, in create_connection for res in getaddrinfo(host, port, 0, SOCK_STREAM): File "/usr/lib/python3.8/socket.py", line 918, in getaddrinfo for res in _socket.getaddrinfo(host, port, family, type, proto, flags): TypeError: getaddrinfo() argument 1 must be string or None

ashutoshkrris commented 2 years ago

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

BidyutBikashBharali commented 2 years ago

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

ashutoshkrris commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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

ashutoshkrris commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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

BidyutBikashBharali commented 2 years ago

Sure

BidyutBikashBharali commented 2 years ago

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 commented 2 years ago

Wait, I'll send you the URL

ashutoshkrris commented 2 years ago

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

BidyutBikashBharali commented 2 years ago

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

ashutoshkrris commented 2 years ago

Please check this: https://res.cloudinary.com/dlomjljb6/image/upload/v1635352489/139104800-261f8c34-531e-4669-b03e-09b9b679a369_u7fka7.png

BidyutBikashBharali commented 2 years ago

Okay, Now it's working

BidyutBikashBharali commented 2 years ago

Capture

Please suggest if any change needed!

ashutoshkrris commented 2 years ago

Amazing!!!

BidyutBikashBharali commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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

ashutoshkrris commented 2 years ago

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

BidyutBikashBharali commented 2 years ago

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

ashutoshkrris commented 2 years ago

To avoid merge conflicts

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