Skip to content

Commit 19df025

Browse files
chore: Refactor the config variables to keep it consistent with earlier versions
1 parent 7af76d0 commit 19df025

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

mftp/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,11 +230,11 @@ _Now that the environment has been set up and configured to properly compile and
230230
- ##### Using SMTP
231231
> `--smtp`
232232
- [Create an app password](https://support.google.com/accounts/answer/185833?hl=en) for the senders' email.
233-
- After creating app password use it as your `SMTP_PASS` value in next step.
233+
- After creating app password use it as your `FROM_EMAIL_PASS` value in next step.
234234
- ##### Using GMAIL API
235235
> `--gmail-api`
236236
- Follow this [quick start guide](https://developers.google.com/gmail/api/quickstart/python) to configure _gmail api_ on the senders' mail.
237-
- After successfull configuration of gmail api, you can leave the value of `SMTP_PASS` as it is in the next step.
237+
- After successfull configuration of gmail api, you can leave the value of `FROM_EMAIL_PASS` as it is in the next step.
238238
- Save the generated token as `mail_send_token.json`
239239

240240
4. #### Configuring environment variables

mftp/env.example.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,11 @@
4646

4747
# EMAIL
4848
## Senders' Credentials (via SMTP)
49-
SMTP_HOST = "smtp.gmail.com"
50-
SMTP_USER = "xxxxxxxxxxxxxxxxxxxx" # Same as FROM_EMAIL in case of Gmail SMTP
51-
SMTP_PASS = "xxxxxxxxxxxxxxxxxxxx" # App password in case of Gmail SMTP
5249
FROM_EMAIL = "[email protected]" # Notification Sender Email-id
50+
# SMTP Credentials
51+
SMTP_HOST = "smtp.gmail.com"
52+
FROM_EMAIL_USER = "xxxxxxxxxxxxxxxxxxxx" # Same as FROM_EMAIL in case of Gmail SMTP
53+
FROM_EMAIL_PASS = "xxxxxxxxxxxxxxxxxxxx" # App password in case of Gmail SMTP
5354
## EMAIL - Receiver's Address
5455
BCC_EMAIL_S = ["[email protected]", "[email protected]"] # Multiple mails for bcc
5556
# BCC_EMAIL_S = ["[email protected]"] # This is how you can set single mail in a list

mftp/mail.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from email.mime.text import MIMEText
66
from email.mime.base import MIMEBase
77
from email.mime.multipart import MIMEMultipart
8-
from env import FROM_EMAIL, SMTP_HOST, SMTP_USER, SMTP_PASS, BCC_EMAIL_S, HOSTER_EMAIL, HOSTER_INTERESTED_ROLLS, HOSTER_NAME, ROLL_MAIL, ROLL_NAME
8+
from env import FROM_EMAIL, SMTP_HOST, FROM_EMAIL_USER, FROM_EMAIL_PASS, BCC_EMAIL_S, HOSTER_EMAIL, HOSTER_INTERESTED_ROLLS, HOSTER_NAME, ROLL_MAIL, ROLL_NAME
99

1010

1111
def send_shortlists(mails, gmail_api, smtp):
@@ -41,7 +41,7 @@ def send_shortlists(mails, gmail_api, smtp):
4141
with smtplib.SMTP_SSL(SMTP_HOST, 465, context=context) as server:
4242
logging.info(" [Connected!]")
4343
try:
44-
server.login(SMTP_USER, SMTP_PASS)
44+
server.login(FROM_EMAIL_USER, FROM_EMAIL_PASS)
4545
logging.info(" [Logged In!]")
4646
except Exception as e:
4747
logging.error(f" Failed to log in ~ {str(e)}")
@@ -176,7 +176,7 @@ def send_companies(mail, gmail_api, smtp):
176176
with smtplib.SMTP_SSL(SMTP_HOST, 465, context=context) as server:
177177
logging.info(" [Connected!]")
178178
try:
179-
server.login(SMTP_USER, SMTP_PASS)
179+
server.login(FROM_EMAIL_USER, FROM_EMAIL_PASS)
180180
logging.info(" [Logged In!]")
181181
except Exception as e:
182182
logging.error(f" Failed to log in ~ {str(e)}")
@@ -290,7 +290,7 @@ def send_notices(mails, smtp, gmail_api, notice_db):
290290
with smtplib.SMTP_SSL(SMTP_HOST, 465, context=context) as server:
291291
logging.info(" [Connected!]")
292292
try:
293-
server.login(SMTP_USER, SMTP_PASS)
293+
server.login(FROM_EMAIL_USER, FROM_EMAIL_PASS)
294294
logging.info(" [Logged In!]")
295295
except Exception as e:
296296
logging.error(f" Failed to log in ~ {str(e)}")

0 commit comments

Comments
 (0)