Skip to content

Commit

Permalink
Merge pull request #1 from LyubomirT/main
Browse files Browse the repository at this point in the history
Simplify SMTP server selection logic.
  • Loading branch information
JohnKun136NVCP authored Jun 21, 2024
2 parents 78db58f + b0790e8 commit 1a91671
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 1a91671

Please sign in to comment.