Skip to content

Commit

Permalink
refactor: simplify SMTP server selection logic
Browse files Browse the repository at this point in the history
  • Loading branch information
LyubomirT committed Jun 20, 2024
1 parent 78db58f commit b0790e8
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions modules/smtp.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,18 +146,17 @@ def bodyContext(self):
def __smtpGet(self):
#Using regex for search the email domain and return it
self.domain = re.search(r"@[\w.]+",self.__usermail).group()
if self.domain == '@gmail.com':
self.__smtpService = 'smtp.gmail.com'
return self.__smtpService
elif self.domain == '@outlook.com' or self.domain == '@hotmail.com':
self.__smtpService = 'smtp-mail.outlook.com'
return self.__smtpService
elif self.domain == '@yahoo.com':
self.__smtpService = 'smtp.mail.yahoo.com'
domaindict = {
'@gmail.com':'smtp.gmail.com',
'@outlook.com':'smtp-mail.outlook.com',
'@hotmail.com':'smtp-mail.outlook.com',
'@yahoo.com':'smtp.mail.yahoo.com'
}
if self.domain in domaindict:
self.__smtpService = domaindict[self.domain]
return self.__smtpService
else:
#If the domain doesn't exist then returns to 'localhost'
self.__smtpService == 'localhost'
self.__smtpService = 'localhost'
return self.__smtpService
#Gets the token
def tokenKey(self):
Expand Down

0 comments on commit b0790e8

Please sign in to comment.