niss3n / webscraper

I want to create a web scraper that sends out email updates when something (in this case, weights) comes back in stock!
0 stars 2 forks source link

Add Send Grid for email notifications #4

Closed niss3n closed 3 years ago

niss3n commented 4 years ago

docs: https://docs.microsoft.com/en-us/azure/sendgrid-dotnet-how-to-send-email

The API Key is already in key vault.

jiyoungsin commented 3 years ago

Hey would It be cool for me to solve this issue?

jiyoungsin commented 3 years ago

just a heads up that Python3 breaks backwards compatibility. Sendgrid requires Python 2.6, 2.7, 3.4 or 3.5. we can roll back to python 3.5. Its your choice!

jiyoungsin commented 3 years ago

If youre open to the idea of other ways of sending email's. I have created a simple solution to your problem using smtplib which is downloaded by default on all macs, however, It comes with configuration variables that must be configured. https://www.afternerd.com/blog/how-to-send-an-email-using-python-and-smtplib/

niss3n commented 3 years ago

Hey Paul!

The nice thing about using SendGrid is that it uses Microsoft's SMPT server and we can authenticate using an API Key vs a username and password. Plus you can have it come from any email address you want. I currently have this working using python 3.8 (might be a recent feature though?) in a different project. Here is an example of that:


import os from sendgrid import SendGridAPIClient from sendgrid.helpers.mail import Mail

def SendGridEmail(): print("sending email") message = Mail( from_name ='John Doe', from_email='fromme@fromme.com', to_emails='tome@tome.com', subject='This is my Subject!', html_content='')

token = "#{SendGridApiKey}#" # This will not change, the pipeline uses

token replacement to get the variable. sg = SendGridAPIClient(token) resonse = sg.send(message)

SendGridEmail()

Let me know if you have any questions!

-Brad

On Thu, Oct 22, 2020 at 2:42 AM Paul Sin notifications@github.com wrote:

If youre open to the idea of other ways of sending email's. I have created a simple solution to your problem using smtplib which is downloaded by default on all macs, however, It comes with configuration variables that must be configured.

https://www.afternerd.com/blog/how-to-send-an-email-using-python-and-smtplib/

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/niss3n/webscraper/issues/4#issuecomment-714369982, or unsubscribe https://github.com/notifications/unsubscribe-auth/AF7S4BK7K2MJTG4WXQJ4XPLSL747XANCNFSM4SUXX7UQ .

jiyoungsin commented 3 years ago

Would it be okay if I got this task assigned?

jiyoungsin commented 3 years ago

Hey niss3n, I too got sendgrid working on my python. even though it says that on their main page. Someone should change that documentation. I noticed my main problem was the google security.

Screen Shot 2020-10-22 at 11 24 40 PM

This setting kept denying my log in attempt.

jiyoungsin commented 3 years ago

I have just created a pull request regarding sendgrid. Everything works locally, however, when others or yourself use it you might have to sign up for a sendgrid account and use your own API key.

niss3n commented 3 years ago

Sendgrid has been integrated and the Issue has been closed.