Skip to content

Commit 66f32c8

Browse files
committed
first commit, project restructuring
0 parents  commit 66f32c8

11 files changed

+289
-0
lines changed

.gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.idea
2+
.pyc
3+
4+
*.egg
5+
*.egg-info
6+
dist
7+
build

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 Stevemats
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

MANIFEST.in

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
include LICENSE
2+
include README.md
3+
recursive-include chi_mailer *
4+
recursive-include samples *

README.md

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# [Chi_Mailer](https://github.com/stevemats/chi_mailer)
2+
3+
### USAGE:
4+
5+
Chi_Mailer is a python script to for mass mailing. With it you can forget the
6+
hastle of having to mail messages an email after an email. You can just write
7+
your message one and the email we'll automate the rest at your comfort.
8+
All you have to do is geek with chi_mailer, take a cup of coffee all whatever you
9+
use, and the rest we'll be done for you.
10+
11+
# New Features!
12+
- Ability to send bulk/mass emails
13+
- Abilty to input your server's credential at script startup so that you don't
14+
have to stress yourself with script alteration.
15+
- Ability to hide your server credential at input to avoid bad spectator eyes from
16+
seeing your password.
17+
- Ability to use the script with or with no python knowledge.
18+
19+
# Installation
20+
chi_mailer at the moments requires [python3+](https://python.org/) at the moment
21+
22+
##### linux users:
23+
24+
Run the following command in the project's root folder via terminal(.i.e after
25+
extracting chi_mailer, open the chi_mailer folder and right-click to open the
26+
terminal, that way you'll be in the projects root folder and type python Qi.py)
27+
```
28+
Method 2:
29+
Change directory using the 'cd' command to enter into the project's folder
30+
$ cd chi_mailer (To enter into the project's directory)
31+
$ ls (To view the content in the directory)
32+
$ python3 Qi.py
33+
```
34+
##### windows users:
35+
36+
Method 1
37+
After extracting the chi_mailer download, double click to enter to the project's
38+
root folder, and hold shift and right click to open powershell or cmd(command prompt)
39+
```
40+
Method 2:
41+
Via startbar type or navigate to command prompt and run as an adminstrator
42+
Now inside the command prompt lets navigate to the project's folder
43+
44+
> cd downloads
45+
> ls (To view the content in the directory)
46+
> cd chi_mailer (Change directory to ch_mailer folder)
47+
> python3 Qi.py (run our python script)
48+
```
49+
50+
The message.txt is where your message should be put as a simple and fast way of calling our message which uses a concept known as templating string within our document from the script and avoiding code alteration.
51+
The mass mails where the message will be sent to should be put in contacts.txt document following the sample.txt format.
52+
53+
### Development
54+
55+
The project is open for contribution.
56+
57+
### Todos
58+
59+
- Convert all user input mails to lowercase. (Humans are prone to errors/typos)
60+
- Time interval to enable code to send mails and repeat again after a certain time
61+
- Code Compatibility to enable all users use the script.
62+
63+
License
64+
----
65+
66+
MIT
67+
68+
NB:---> The server mail needs to be given privilege for your script to act as a stand alone,
69+
visit( https://myaccount.google.com/security ) and enable less secure apps to give your
70+
script power. Mail server is set to use gmail at default.
71+
72+
73+
**Stay Safe and Enjoy Your new free Mail Server!**

chi_mailer/Qi.py

+129
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
#!/usr/bin/env/python
2+
# -*- coding: utf-8 -*-
3+
from __future__ import print_function
4+
5+
try:
6+
import smtplib
7+
except:
8+
print("{ smtplib module is missing. Try installing it and try again }\n")
9+
exit(-1)
10+
import time
11+
import sys
12+
13+
from email.mime.multipart import MIMEMultipart
14+
from email.mime.text import MIMEText
15+
from getpass import getpass
16+
from string import Template
17+
18+
'''
19+
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
20+
$$ $$
21+
$$ This project was written for EDUCATION PURPOSE ONLY to understand the SMTP $$
22+
$$ functionality as part of python programming. Any illegal use of the tool $$
23+
$$ such as spamming is strictly prohibited without the users consent/knowledge $$
24+
$$ STAY SAFE AND KEEP CODING $$
25+
$$ !THE FUTURE IS IN THE HANDS OF OPEN SOURCE DEVELOPERS! $$
26+
$$ $$
27+
$$ $$
28+
$$ By Stevemats &fkinaro $$
29+
$$ $$
30+
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
31+
'''
32+
print('''
33+
34+
35+
__
36+
o /' )
37+
/' ( ,
38+
__/' ) .' `;
39+
o _.-~~~~' ``---..__ .' ;
40+
_.--' b) ``--...____.' .'
41+
( _. )). `-._ < The green shark world!!
42+
`\|\|\|\|)-.....___.- `-. __...--'-.'.
43+
stv `---......____...---`.___.'----... .' `.;
44+
`-` `
45+
''')
46+
try:
47+
SERVER_MAIL = input("\n >>>Enter your server email_address:".lower())
48+
PASSWORD = getpass(">>>Input your password:") # 'Your server email password'
49+
except NameError:
50+
input = raw_input # python 2
51+
52+
53+
def slowprint(thrasher):
54+
for n in thrasher + '\n':
55+
sys.stdout.write(n)
56+
sys.stdout.flush()
57+
time.sleep(10. / 100)
58+
59+
60+
slowprint("Congratulation! Now you can Take a sip of coffee as we automate your mail delivery... ")
61+
time.sleep(5)
62+
63+
64+
def get_contacts(filename):
65+
"""
66+
Return two lists names, emails containing names and email addresses
67+
read from a file specified by filename.
68+
"""
69+
70+
names = []
71+
emails = []
72+
with open(filename, mode='r', encoding='utf-8') as contacts_file:
73+
for a_contact in contacts_file:
74+
names.append(a_contact.split()[0])
75+
emails.append(a_contact.split()[1])
76+
return names, emails
77+
78+
79+
def read_template(filename):
80+
"""
81+
Returns a Template object comprising the contents of the
82+
file specified by filename.
83+
"""
84+
85+
with open(filename, 'r', encoding='utf-8') as template_file:
86+
template_file_content = template_file.read()
87+
return Template(template_file_content)
88+
89+
90+
def main():
91+
""" TODO: code functionality to lower all input mails to lowercase $ validate"""
92+
names, emails = get_contacts('contacts.txt') # read contacts(email and username)
93+
message_template = read_template('message.txt') # read message(your mail content)
94+
95+
# Highly define your SMTP server here
96+
s = smtplib.SMTP(host='smtp.gmail.com', port=587)
97+
s.starttls()
98+
s.login(SERVER_MAIL, PASSWORD)
99+
100+
# For each contact, send the email:
101+
for name, email in zip(names, emails):
102+
msg = MIMEMultipart() # create a message
103+
104+
# add in the actual person name to the message template
105+
message = message_template.substitute(PERSON_NAME=name.title())
106+
107+
# Prints out the message body for our sake(not necessary)
108+
print(message)
109+
110+
# setup the parameters of the message
111+
msg['From'] = SERVER_MAIL
112+
msg['To'] = email
113+
msg['Subject'] = "This is Just A Sample Mail Test"
114+
115+
# add in the message body
116+
msg.attach(MIMEText(message, 'plain'))
117+
118+
# send the message via the server set up earlier.
119+
""" TODO: code functionality to send mails at an interval to avoid red flags $ meet limits"""
120+
s.send_message(msg)
121+
del msg
122+
123+
# s = your_server
124+
s.quit()
125+
print("Email successfully sent.")
126+
127+
128+
if __name__ == '__main__':
129+
main()

chi_mailer/__init__.py

Whitespace-only changes.

chi_mailer/contacts.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

chi_mailer/messages.txt

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Dear ${PERSON_NAME},
2+
3+
Am written to inform you that..
4+
Have a great day!
5+
6+
Yours Truly,
7+
Lorem sample.

samples/sample_contact.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
3+
sample, yahoo.com

samples/sample_message.txt

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Dear ${PERSON_NAME},
2+
3+
Am written to inform you that..
4+
The ${Person_Name} is a python templating method,
5+
to enable us call the username from all the emails in contact.txt,
6+
one after the other by there username. You can imagine typing the username
7+
one after another for all the email recipient how tedious it would be.
8+
Hence the reason to use the method.
9+
10+
Have a great day!
11+
12+
Yours Truly,
13+
Lorem sample.

setup.py

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env python3
2+
# encoding: utf-8
3+
4+
import os
5+
from setuptools import setup, find_packages
6+
7+
with open(os.path.join(os.path.dirname(__file__), 'README.md')) as readme:
8+
README = readme.read()
9+
10+
setup(
11+
name="chi_mailer",
12+
version="1.0",
13+
packages=find_packages(),
14+
include_package_data=True,
15+
author="Stevemats & fkinaro",
16+
author_email="[email protected]",
17+
license='BSD License',
18+
description="python bulk/mass mailer package",
19+
long_description=README,
20+
long_description_content_type="text/markdown",
21+
url="https://github.com/stevemats/chi_mailer",
22+
classifiers=[
23+
"Environment :: Console",
24+
"Intended Audience :: Developers",
25+
"Programming Language :: Python :: 3",
26+
"License :: OSI Approved :: MIT License",
27+
"Operating System :: OS Independent",
28+
"Topic :: Software Development :: Libraries :: Python Modules",
29+
"Topic :: Utilities",
30+
],
31+
)

0 commit comments

Comments
 (0)