Skip to content

Commit

Permalink
Added code for #35
Browse files Browse the repository at this point in the history
  • Loading branch information
chauhannaman98 committed May 24, 2020
1 parent e7c433c commit c64dadb
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
47 changes: 47 additions & 0 deletions resources/SMTP-email/SMTP-test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import smtplib, random, string
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart

toaddrs = input("Enter your email ID: ")
username = '[email protected]'
password = 'passwordnahihai'
x = ''.join(random.choices(string.ascii_letters + string.digits, k=12))

message = MIMEMultipart("alternative")
message["Subject"] = "Forgot Password | MedFixture"
message["From"] = username
message["To"] = toaddrs

html = """\
<html>
<body>
<h1 align="center">Hi! Seems like you forgot you password. </h1>
<p align="center">Don't worry! Just enter the verification code
given below.</p>
<p align="center">Your verification code is <code>"""+ x +"""</code></p>
</body>
<footer align="center">Project maintained by
<a href="https://github.com/chauhannaman98">chauhannaman98</a></footer>
</html>
"""

part1 = MIMEText(html, "html")
message.attach(part1)


try:
server = smtplib.SMTP('smtp.gmail.com:587')
server.ehlo()
server.starttls()
server.login(username,password)
server.sendmail(username, toaddrs, message.as_string())
except Exception as e:
print(e)
finally:
server.quit()

in_code = input("Enter the verification code: ")
if in_code == x:
print("Verification successful")
else:
print("Enter correct verification code")
10 changes: 10 additions & 0 deletions resources/SMTP-email/email.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<html>
<body>
<h1 align="center">Hi! Seems like you forgot you password. </h1>
<p align="center">Don't worry! Just enter the verification code
given below.</p>
<p align="center">Your verification code is <code>"""+ x +"""</code></p>
</body>
<footer align="center">Project maintained by
<a href="https://github.com/chauhannaman98">chauhannaman98</a></footer>
</html>

0 comments on commit c64dadb

Please sign in to comment.