Skip to content

Commit 33e000d

Browse files
Merge pull request prathimacode-hub#977 from dilroseR/issue-#951
html mail sender
2 parents 7f0d6f9 + ee696b2 commit 33e000d

File tree

6 files changed

+149
-0
lines changed

6 files changed

+149
-0
lines changed
59 KB
Loading

GUIScripts/HTML Mail Sender/README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
### Package/Script Name
2+
**Aim**
3+
The main aim of the project is to make an HTML Mail sender which would send mail to multiple recepients at a time.
4+
5+
### Purpose
6+
Occasionally we need to send emails to more than one person.
7+
For eg: If you are in sales, marketing or recruitment field, then most of the times, you have to send a single email to multiple recipients and hence it was very important to build this project
8+
9+
10+
### Short description of package/script
11+
Its a simple front end project which makes help of flask
12+
Libraries used: flask
13+
14+
### Workflow of the Project
15+
- Go to app.py and type python app.py in the terminal, it will give a link
16+
- Ctrl + click on the link and it will take you to the website
17+
- give in all the details as said there
18+
- Click send, your mail is sent to the mentioned recepients.
19+
20+
### Compilation Steps
21+
- Install python.
22+
- Import the neccessary modules
23+
- If you want to change the sender mail id, then go to app.py, in the **app.config['MAIL_USERNAME']** section change the sender mail id and in the **app.config['MAIL_PASSWORD']** section give in the password of the sender's mail id
24+
- Go to app.py and type python app.py in the terminal, it will give a link
25+
- Ctrl + click on the link and it will take you to the website
26+
27+
### Output
28+
29+
<img src="E:\github\Awesome_Python_Scripts\GUIScripts\HTML Mail Sender\Images\img.PNG" alt="None">
30+
31+
### Author(s)
32+
Dilrose Reji

GUIScripts/HTML Mail Sender/app.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# import required libraries
2+
from flask import Flask, render_template, request, flash
3+
from flask_mail import Mail, Message
4+
5+
app = Flask(__name__)
6+
app.secret_key = 'hello123'
7+
8+
app.config['MAIL_SERVER'] = "smtp.gmail.com"
9+
app.config['MAIL_PORT'] = 587
10+
app.config['MAIL_USERNAME'] = 'dreji1234@gmail.com'
11+
app.config['MAIL_PASSWORD'] = 'Abc45678*'
12+
app.config['MAIL_USE_TLS'] = True
13+
app.config['MAIL_USE_SSL'] = False
14+
mail = Mail(app)
15+
16+
# routes of url
17+
@app.route('/')
18+
def home():
19+
flash("This is a flashed message.")
20+
return render_template('home.html')
21+
22+
# data given in the form comes here
23+
@app.route('/send', methods=['POST','GET'])
24+
def send():
25+
s= ""
26+
em = request.form['em']
27+
sub = request.form['sub']
28+
body = request.form['body']
29+
s=em.split(",")
30+
n=len(s)
31+
for i in range(0,n):
32+
33+
msg = Message(sub, sender='dreji1234@gmail.com', recipients=[s[i]])
34+
msg.body = body
35+
mail.send(msg)
36+
i=i+1
37+
return render_template('home.html',msg=1)
38+
39+
40+
41+
42+
43+
if __name__ == '__main__':
44+
app.run(debug=True)
45+
46+
47+
48+
49+
50+
51+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Libraries used
2+
- flask
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
p, form{
2+
font-size: 18px;
3+
}
4+
5+
h1{
6+
color: rgb(109, 67, 67);
7+
}
8+
9+
.d1{
10+
background-color: rgb(196, 189, 183);
11+
height: 800px;
12+
width: 750px;
13+
border-radius: 50px;
14+
}
15+
16+
body{
17+
background-color: rgb(255, 255, 246);
18+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<html>
2+
<head>
3+
<title>HTML Mail Sender</title>
4+
<!-- CSS only -->
5+
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-KyZXEAg3QhqLMpG8r+8fhAXLRk2vvoC2f3B09zVXn8CA5QIVfZOJ3BCsw2P0p/We" crossorigin="anonymous">
6+
<link rel="stylesheet" href="static/main.css">
7+
8+
9+
</head>
10+
11+
<body>
12+
<center>
13+
{% if(msg == 1) %}
14+
<div class="alert alert-dark" role="alert">
15+
Mail sent!(Check the spam folder too)
16+
</div>
17+
{% endif %}
18+
19+
<!--A form which accepts all inputs given by the user-->
20+
<div class="d1">
21+
<h1 style="padding: 5px; margin-top:10px;"><b>HTML Mail Sender App</b></h1>
22+
<p>If you intend to send mail to more than 1 person; kindly put <strong>" , "</strong> to separate the e-mail addresses</p>
23+
<p><b>NOTE:</b> Do not put any spaces between the addresses.</p>
24+
<form action="/send" method="POST">
25+
<textarea style="resize: none;" name="em" id="em" cols="30" rows="8" placeholder="Enter e-mail address"></textarea>
26+
27+
<br><br>
28+
<input type="text" name="sub" id="sub" placeholder="Enter subject line">
29+
<br><br>
30+
<textarea style="resize: none;" name="body" id="body" cols="30" rows="6" placeholder="Enter the message to be sent"></textarea>
31+
<br><br>
32+
<p><b>Kindly verify everything before sending</b></p>
33+
34+
<button type="submit" class="btn btn-dark" id="b1">Send</button>
35+
36+
</form>
37+
38+
</div>
39+
40+
41+
<br>
42+
43+
44+
</center>
45+
</body>
46+
</html>

0 commit comments

Comments
 (0)