Advertisement
Guest User

Untitled

a guest
Aug 12th, 2018
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. const express = require('express');
  2. const nodemailer = require('nodemailer');
  3. const app = express();
  4.  
  5. const transporter = nodemailer.createTransport({
  6. host: 'cpsrv07.misshosting.com',
  7. port: 465,
  8. secure: true,
  9. auth: {
  10. user: 'info@jackistyle.se',
  11. pass: '<your-password-here>'
  12. }
  13. })
  14.  
  15. app.get('/', (req, res) => res.send('Hello World!'))
  16.  
  17.  
  18. app.post('/register',function(req,res){
  19. const email = req.query.email
  20.  
  21. transporter.sendMail({
  22. from: 'info@jackistyle.se',
  23. to: 'info@jackistyle.se',
  24. subject: 'New sign up!',
  25. text: email,
  26. html: email
  27. }).then((info) => {
  28. console.log(`Sent email to ${email}`)
  29. res.json({ result: 'ok' })
  30. }).catch((e) => {
  31. console.error(e)
  32. res.status(500).json({ result: 'error' })
  33. })
  34. })
  35.  
  36. const port = process.env.PORT || 3000
  37.  
  38. app.listen(port, () => console.log(`Server started on port ${port}`))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement