Hey there! This project will help you spread some mails around with a simple RestFUL API.
Anyone who already has a SMTP server and whouldn't want to pay for third-party services.
Sometimes you just need to be able to let your users send a mail with a click of a button.
- You may have a static website that doesn't have any SMTP logic (or no back-end at all).
- You might have a full-scale application that has it's own SMTP integration, but it has it's own rules (styling or event-triggered) that you'd wish to bypass.
Mail Man would let you define your own HTML files as templates for mailing. You can embed parameters inside of that HTML and sent their values on your request.
I'm free to use! Just rememeber to credit.
If you wish to install this as a standalone server, just contact me for help.
If you wish to make changes, you'll have to get Python 3.6.4 or above installed. Then:
- Install with
pip install -r requirements.txt
. - Make sure to configure your organization's SMTP server in a
config.xml
file. You may useconfig.example.xml
for reference. - Run mailMan.py with the the name of your SMTP server as first param, and optional port (default: 5000) as second param (i.e.,
python mailMan.py Gmail [8080]
).
You can create a fake SMTP server with Ethereal.
With Gmail, you must allow "Less secure apps".
- If you made changes to the code, you might want to edit
mailMan.spec
. See here. - No changes to the spec file needed? Good! just run
pyinstaller mailMan.spec
. - After pyinstaller is done, MailMan is ready inside of
dist
folder. - You may run
MailMan.exe
with the server name and port params or use NSSM to install it as a service. - To run the server on HTTPS, add a
server.crt
andserver.key
files tocertificates
folder.
$.ajax({
url: 'http://**ServerDNSOrIP**:**Port**/sendMail',
type: 'post',
contentType: 'application/json; charset=utf-8',
success: function (data){
//Do something when you're done;
},
data: JSON.stringify(
{
"t" : "message", //Name of the template you're using
"to" : "[email protected]",
"cc" : "[email protected]",
"bcc" : "[email protected]",
"sp" : { //Subject parameters (embedded inside the HTML <subject> tag)
"TaskName" : "A New Task"
},
"bp" : { //Body parameters (embedded inside of the HTML body)
"TaskDescription" : "Develop A Thingy"
}
}
)
})
Please refer to message.html to see how parameters are set.
You can either add .html files manually or upload them. Refer to http://**ServerDNSOrIP**:**Port**/templates
for all the relevant info regarding tamplates.