Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
GroupKemailSystem
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Group K email system
GroupKemailSystem
Commits
f1d32602
Commit
f1d32602
authored
1 year ago
by
Ismailn16
Browse files
Options
Downloads
Patches
Plain Diff
initial email sending function done
parent
b4851c51
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
main.py
+27
-14
27 additions, 14 deletions
main.py
templates/test.html
+1
-1
1 addition, 1 deletion
templates/test.html
with
28 additions
and
15 deletions
main.py
+
27
−
14
View file @
f1d32602
from
flask
import
Flask
,
render_template
,
request
from
flask
import
Flask
,
render_template
,
request
from
flask_mail
import
Mail
,
Message
from
flask_mail
import
Mail
,
Message
import
os
app
=
Flask
(
__name__
)
app
=
Flask
(
__name__
)
mail
=
Mail
(
app
)
app
.
config
[
'
MAIL_SERVER
'
]
=
'
smtp.gmail.com
'
app
.
config
[
'
MAIL_SERVER
'
]
=
'
smtp.gmail.com
'
app
.
config
[
'
MAIL_PORT
'
]
=
587
app
.
config
[
'
MAIL_PORT
'
]
=
587
app
.
config
[
'
MAIL_USE_TLS
'
]
=
True
app
.
config
[
'
MAIL_USE_TLS
'
]
=
True
app
.
config
[
'
MAIL_USE_SSL
'
]
=
False
app
.
config
[
'
MAIL_USE_SSL
'
]
=
False
app
.
config
[
'
MAIL_USERNAME
'
]
=
'
UWEITSTestEmail@gmail.com
'
app
.
config
[
'
MAIL_USERNAME
'
]
=
'
uweitstestemail@gmail.com
'
app
.
config
[
'
MAIL_PASSWORD
'
]
=
'
ITPtesting2024
'
app
.
config
[
'
MAIL_PASSWORD
'
]
=
os
.
environ
.
get
(
'
its_password
'
)
mail
=
Mail
(
app
)
@app.route
(
'
/home
'
)
@app.route
(
'
/home
'
,
methods
=
[
'
GET
'
,
'
POST
'
]
)
@app.route
(
'
/
'
)
@app.route
(
'
/
'
)
def
home
():
def
home
():
return
render_template
(
'
test.html
'
)
return
render_template
(
'
test.html
'
)
#def send_email():
@app.route
(
'
/process_form
'
,
methods
=
[
'
POST
'
])
# user_firstname = request.form('firstname')
def
process_data
():
# user_lastname = request.form('lastname')
user_firstname
=
request
.
form
[
'
firstname
'
]
# user_email = request.form('UWEemail')
user_lastname
=
request
.
form
[
'
lastname
'
]
# user_issue = request.form('issue')
user_email
=
request
.
form
[
'
UWEemail
'
]
# user_info = request.form('furtherinfo')
user_issue
=
request
.
form
[
'
issue
'
]
user_info
=
request
.
form
[
'
furtherinfo
'
]
# if 'live.uwe.ac.uk' in user_email:
result
=
send_email
(
user_email
)
# if user_issue == 'issue1':
# if 'password' & 'forgot' in user_info:
return
result
app
.
route
(
'
/send_email
'
,
methods
=
[
'
POST
'
])
def
send_email
(
user_email
):
if
'
live.uwe.ac.uk
'
in
user_email
:
msg
=
Message
(
"
UWE ITS Help Service
"
,
sender
=
'
uweitstestemail@gmail.com
'
,
recipients
=
[
user_email
])
msg
.
body
=
"
Hi, This is a test email as we are currently prototyping. Thank you for your support.
"
mail
.
send
(
msg
)
return
"
Email sent.
"
else
:
return
"
This email isn
'
t a UWE Email, Goodbye.
"
if
__name__
==
'
__main__
'
:
if
__name__
==
'
__main__
'
:
app
.
run
(
debug
=
True
)
app
.
run
(
debug
=
True
,
host
=
'
0.0.0.0
'
,
port
=
5000
)
\ No newline at end of file
\ No newline at end of file
This diff is collapsed.
Click to expand it.
templates/test.html
+
1
−
1
View file @
f1d32602
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
</head>
</head>
<body>
<body>
<form
method=
"post"
action=
""
>
<form
method=
"post"
action=
"
/process_form
"
>
<div>
<div>
<label
for=
"firstname"
>
First Name:
</label>
<label
for=
"firstname"
>
First Name:
</label>
<input
type=
"text"
id=
"firstname"
placeholder=
"Please enter your first name"
name=
"firstname"
required
>
<input
type=
"text"
id=
"firstname"
placeholder=
"Please enter your first name"
name=
"firstname"
required
>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment