Created
July 17, 2018 17:46
-
-
Save juliojgarciaperez/8bc169ff9775ac9da80598d020b515a0 to your computer and use it in GitHub Desktop.
Simple mailer service example
This file contains hidden or 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 nodemailer = require('nodemailer'); | |
const transporter = nodemailer.createTransport({ | |
service: 'Gmail', | |
auth: { | |
user: process.env.EMAIL_SENDER, | |
pass: process.env.EMAIL_PASSWORD | |
} | |
}); | |
const defaultFrom = process.env.EMAIL_SENDER | |
module.exports.confirmSignUp = (user) => { | |
return transporter.sendMail({ | |
from: defaultFrom, | |
to: user.email, | |
subject: 'Confirm SignUp!', | |
html: ` | |
<!DOCTYPE html> | |
<html> | |
<head> | |
</head> | |
<body> | |
... | |
</body> | |
</html> | |
` | |
}); | |
} | |
module.exports.helpRequest = (to, content) => { | |
return transporter.sendMail({ | |
from: defaultFrom, | |
to: to, | |
subject: 'Welcome!', | |
html: ` | |
<!DOCTYPE html> | |
<html> | |
<head> | |
</head> | |
<body> | |
... | |
</body> | |
</html> | |
` | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment