Created
January 15, 2019 13:38
-
-
Save abidkhan484/ccd4f149f24593fb7079c81aebef79d4 to your computer and use it in GitHub Desktop.
send mail for drupal version
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /usr/bin/python3 | |
| from requests import get | |
| from bs4 import BeautifulSoup as bs | |
| from smtplib import SMTP | |
| """ | |
| Allow less secure app: ON | |
| from below link | |
| https://myaccount.google.com/u/3/security#connectedapps | |
| and change frmAddr and passwd | |
| """ | |
| url = "https://www.drupal.org/project/drupal" | |
| response = get(url) | |
| req = 0 | |
| while response.status_code != 200: | |
| response = get(url) | |
| req += 1 | |
| if req == 10: | |
| # i should return with some flash message | |
| break | |
| soup = bs(response.text, "lxml") | |
| msg = soup.select_one("#recommended-releases > div > div > div.view-content > \ | |
| div.views-row.views-row-2.views-row-even.views-row-last > div.views-field.views-field-field-release-version > div > a > h4").text | |
| frmAddr = "[email protected]" | |
| passwd = "my password" | |
| toAddr = "[email protected]" | |
| server = SMTP('smtp.gmail.com',25) | |
| server.connect("smtp.gmail.com",587) | |
| # these could may be secure the connection. i'm just not sure | |
| server.ehlo() | |
| server.starttls() | |
| server.ehlo() | |
| server.login(frmAddr, passwd) | |
| server.sendmail(frmAddr, toAddr,msg) | |
| server.quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment