Skip to content

Commit

Permalink
Merge pull request #86 from brosquinha/develop
Browse files Browse the repository at this point in the history
v0.5.9
  • Loading branch information
brosquinha authored Oct 10, 2020
2 parents c82bd29 + 67c7c86 commit cb61c2f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ A seguir, acesse a pasta raíz do projeto e crie o arquivo `.env` dentro da past
| EMAIL_SSL | `True` se o server SMTP trabalha com SSL |
| EMAIL_TLS | `True` se o server SMTP trabalha com TLS |
| EMAIL_USR | Endereço de email do gmail para envio de relatórios |
| EMAIL_FROM_EMAIL | Endereço de email do gmail para para o campo From |
| EMAIL_PSW | Senha do email do gmail para envio de relatórios |
| FIREBASE_API_TOKEN | Token da API REST legada do Firebase para envio de Push Notifications |
| PORT | Porta para expor a aplicação Flask |
Expand Down
3 changes: 3 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
"EMAIL_USR": {
"required": true
},
"EMAIL_FROM_EMAIL": {
"required": true
},
"FIREBASE_API_TOKEN": {
"required": true
},
Expand Down
5 changes: 3 additions & 2 deletions legislei/send_reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@

smtp_server = os.environ.get("EMAIL_ENDPOINT", "smtp.gmail.com")
smtp_server_port = os.environ.get("EMAIL_PORT", "587")
from_email = os.environ.get("EMAIL_USR", None)
email_user = os.environ.get("EMAIL_USR", None)
from_email = os.environ.get("EMAIL_FROM_EMAIL", email_user)
password = os.environ.get("EMAIL_PSW", None)
uses_ssl = os.environ.get("EMAIL_SSL", "False") in ['True', 'true']
uses_tls = os.environ.get("EMAIL_TLS", "True") in ['True', 'true']
Expand Down Expand Up @@ -49,7 +50,7 @@ def send_email(email, reports, dates):
s = smtplib.SMTP(smtp_server, int(smtp_server_port))
if uses_tls:
s.starttls()
s.login(from_email, password)
s.login(email_user, password)
msg = MIMEText(html_report, 'html', 'utf-8')
msg['Subject'] = Header(u'🇧🇷 Relatório de parlamentares', 'utf-8')
msg['From'] = 'Legislei <{}>'.format(from_email)
Expand Down

0 comments on commit cb61c2f

Please sign in to comment.