Last active
August 2, 2016 07:02
-
-
Save iddan/7631177dc04519780a5f3d17754d718c to your computer and use it in GitHub Desktop.
Hack the Web nodemailer script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const sent = require('./sent.js'); | |
const nodemailer = require('nodemailer'); | |
const PEOPLE = require('./people.js').filter(person => person.Approval === 1).filter(person => !sent.includes(person.Email)); | |
// const PEOPLE = [{ | |
// Email: '[email protected]', | |
// 'Full Name': 'Iddan Aharonson' | |
// }]; | |
let transporter = nodemailer.createTransport({ | |
host: 'smtp.allsafe.com', | |
port: 465, | |
secure: true, // use SSL | |
auth: { | |
user: 'fsociety', | |
pass: 'evilcorp' | |
} | |
}); | |
let promise = Promise.resolve(); | |
for (let person of PEOPLE) { | |
let email = Approval(person); | |
promise.then(() => new Promise(resolve => setTimeout(() => transporter.sendMail({ | |
from: '"Iddan Aharonson" <[email protected]>', // sender address | |
to: person.Email, // list of receivers | |
subject: 'Hack the Web’s Summer Hackathon 2016', // Subject line | |
text: email.txt, // plaintext body | |
html: email.html // html body | |
}, (err, info) => { | |
if (err) | |
console.error(err); | |
else | |
console.log(person.Email); | |
resolve(); | |
}), 10000))); | |
} | |
function Approval (person) { | |
const APPROVAL_TXT = `Hey ${person['Full Name']}, | |
We are glad to inform you that you’ve been accepted to Hack the Web’s Summer Hackathon 2016. | |
Hack the Web is your opportunity to expand your knowledge and horizons and meet new amazing colleagues. Along the event, you’ll develop your own product, which has to be web related, and in the end it will be estimated by our certified judges. More about that on hacktheweb.co/competition | |
The hackathon is expected to take place in the center of Tel Aviv on the 29th-30th of July, But the date might be changed in the following week. The final place and time will be notified to you by email and Facebook. | |
For the hackathon you will need a computer (or any other device you’re using for digital creation), if you intend to sleep along the event, you should bring a sleeping bag, we prefer to see you working, but, you know.. | |
Now, there are 3 steps to complete registration: | |
If you have Facebook, join our participants group https://www.facebook.com/groups/hacktheweb/ | |
Once you have a team, send us an email with the team member names (5 max). | |
Send us a mail back to confirm your participant in the hackathon and save your place! | |
You don't have to join a team before the event but it is recommended. | |
By joining the hackathon you agree to the terms on http://hacktheweb.co/terms | |
Wish you an extraordinary summer, | |
Iddan Aharosnon | |
Hack the Web Founder;`; | |
const APPROVAL_HTML = `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head> | |
<meta charset="utf-8"> | |
<link rel="stylesheet" type="text/css" href="http://hacktheweb.co/css/atlaspro.scss"> | |
<style> | |
body { | |
margin: 0; | |
padding: 0; | |
font-family: 'AtlasPro AAA', "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; | |
} | |
h1, h2 { | |
font-weight: normal; | |
} | |
#hero { | |
padding: .5em; | |
text-align: center; | |
background: -webkit-radial-gradient(bottom left circle, #ff2d42 0%, #0d2d42 70%); | |
background: radial-gradient(circle at bottom left, #ff2d42 0%, #0d2d42 70%); | |
color: #fff; | |
} | |
#hero h1 { | |
font-weight: 100; | |
font-size: 3em; | |
} | |
#hero h2 { | |
font-weight: 200; | |
font-size: 2em; | |
} | |
article { | |
max-width: 60em; | |
padding: 1em; | |
margin: auto; | |
} | |
</style> | |
<meta name=viewport content="width=device-width, initial-scale=1"> | |
</head> | |
<body style="margin: 0;padding: 0;font-family: 'AtlasPro AAA', "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;"> | |
<section id="hero" style="padding: .5em;text-align: center;background: radial-gradient(circle at bottom left, #ff2d42 0%, #0d2d42 70%);color: #fff;"> | |
<h1 style="font-weight: 100;font-size: 3em;">Hack the Web</h1> | |
<h2 style="font-weight: 200;font-size: 2em;">Summer Hackathon 2016</h2> | |
</section> | |
<article id="content" style="max-width: 60em;padding: 1em;margin: auto;"> | |
<p>Hey ${person['Full Name']},</p> | |
<p>We are glad to inform you that you’ve been accepted to Hack the Web’s Summer Hackathon 2016.</p> | |
<p>Hack the Web is your opportunity to expand your knowledge and horizons and meet new amazing colleagues. Along the event, you’ll develop your own product, which has to be web related, and in the end it will be estimated by our certified judges. More about that on <a href="http://hacktheweb.co/competition">hacktheweb.co/competition</a></p> | |
<p>The hackathon is expected to take place in the center of Tel Aviv on the 29th-30th of July, But the date might be changed in the following week. The final place and time will be notified to you by email and Facebook.</p> | |
<p>For the hackathon you will need a computer (or any other device you’re using for digital creation), if you intend to sleep along the event, you should bring a sleeping bag, we prefer to see you working, but, you know…</p> | |
<p>Now, there are 3 steps to complete registration:</p> | |
<ul> | |
<li> | |
If you have Facebook, join our participants group <a href="https://www.facebook.com/groups/hacktheweb/">https://www.facebook.com/groups/hacktheweb/</a> | |
</li> | |
<li> | |
Once you have a team, send us an email with the team member names (5 max). | |
</li> | |
<li> | |
Send us a mail back to confirm your participant in the hackathon and save your place! | |
</li> | |
</ul> | |
<p>You don’t have to join a team before the event but it is recommended.</p> | |
<p>By joining the hackathon you agree to the terms on <a href="http://hacktheweb.co/terms">http://hacktheweb.co/terms</a></p> | |
<p> | |
Wish you an extraordinary summer, | |
</p> | |
<p> | |
Iddan Aharosnon<br> | |
Hack the Web Founder | |
</p> | |
</article></body> | |
</html> | |
`; | |
return { | |
html: APPROVAL_HTML, | |
txt: APPROVAL_TXT | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment