Add email smtp library in core directory
This commit is contained in:
parent
8965253222
commit
5cfeb87627
@ -3,6 +3,7 @@ import os
|
||||
# For templating
|
||||
page = "static/page"
|
||||
template = "static/template"
|
||||
email = "static/email"
|
||||
|
||||
# For route
|
||||
dirconfig = {
|
||||
|
@ -7,6 +7,7 @@ class main:
|
||||
# Declare a variables
|
||||
self.html_page = html.main.get_html(directory.page)
|
||||
self.html_template = html.main.get_html(directory.template)
|
||||
self.html_email = html.main.get_html(directory.email)
|
||||
|
||||
def user(self, page):
|
||||
params_list = {
|
||||
@ -16,3 +17,9 @@ class main:
|
||||
"container" : self.html_page [ page+".html" ]
|
||||
}
|
||||
return params_list
|
||||
|
||||
def verification(self):
|
||||
params_list = {
|
||||
"template" : self.html_email ["verification.html" ]
|
||||
}
|
||||
return params_list
|
||||
|
23
core/mailme.py
Normal file
23
core/mailme.py
Normal file
@ -0,0 +1,23 @@
|
||||
from email.mime.multipart import MIMEMultipart
|
||||
from email.mime.text import MIMEText
|
||||
import smtplib
|
||||
|
||||
def smtp(config):
|
||||
|
||||
msg = MIMEMultipart('alternative')
|
||||
msg['Subject' ] = config['subject' ]
|
||||
msg['From' ] = config['from' ]
|
||||
msg['To' ] = config['to' ]
|
||||
|
||||
part1 = MIMEText(config['text'], 'plain')
|
||||
part2 = MIMEText(config['html'], 'html' )
|
||||
|
||||
msg.attach(part1)
|
||||
msg.attach(part2)
|
||||
|
||||
smtp_server = smtplib.SMTP(config['server']['host'], config['server']['port'])
|
||||
smtp_server.ehlo()
|
||||
smtp_server.starttls()
|
||||
smtp_server.login( config['login']['email'], config['login']['password'] )
|
||||
smtp_server.sendmail('&&&&&&', email, msg.as_string() )
|
||||
smtp_server.quit()
|
50
static/email/verification.html
Normal file
50
static/email/verification.html
Normal file
@ -0,0 +1,50 @@
|
||||
<table style="MARGIN:0px auto" border="0" cellspacing="0" cellpadding="0" width="100%" align="center">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="PADDING-BOTTOM:40px;BACKGROUND-COLOR:#f0f0f0;PADDING-LEFT:20px;PADDING-RIGHT:20px;PADDING-TOP:30px">
|
||||
<table border="0" cellspacing="0" cellpadding="0" width="640" align="center">
|
||||
<tbody style="border-radius: 14px; filter: drop-shadow(0px 4px 10px rgba(0, 0, 0, 0.1)); ">
|
||||
<tr bgcolor="#ffffff">
|
||||
<td style="padding: 48px;">
|
||||
<div style="LINE-HEIGHT:1.47em; font-family: Open Sans, sans-serif !important; text-align:left ">
|
||||
<div>
|
||||
<div>
|
||||
<table height="100 " width="100% ">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td width="65% " style="line-height:28.8px; font-family: Open Sans, sans-serif !important; color: #444444 ;font-size:14px; font-weight:normal;text-align:left ">
|
||||
<b style="font-family: Poppins, sans-serif !important; font-size:20px; font-weight:600;">Verify Account</b>
|
||||
<br> Thanks for signing up! This is the start of an exciting journey and you’re just one step away from completing your account setup to start using
|
||||
your profile.
|
||||
<br>
|
||||
<br> Click the button below to verify your account and get started.
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<br>
|
||||
<a href="${link}" style="cursor: pointer; border: unset; padding: 20px; font-size: 16px; color:white; background: #444444; font-weight: 600; ">
|
||||
Verify email address
|
||||
</a>
|
||||
<br><br><br>
|
||||
<div style="background: #eaeaea; padding: 30px 80px; text-align: center; ">
|
||||
<div>
|
||||
<div style="LINE-HEIGHT:21px; fontFamily: Open Sans; COLOR:#7e7e7e; FONT-SIZE:11px; ">
|
||||
Need help?
|
||||
<a style="COLOR:#2284C6;" href="mailto:info@example.com" target="_blank ">Contact our support team</a>
|
||||
<br><br>
|
||||
<div style="border-top: 1px solid #cacaca; padding:3px;padding-left:0px;color:#acacac;font-size:11px;"><br>Your Company | Kota Damansara, 47810 Petaling Jaya, Selangor, Malaysia</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
Loading…
Reference in New Issue
Block a user