Advertisement
Guest User

Untitled

a guest
Aug 4th, 2016
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. var express = require("express"),
  2. app = express();
  3.  
  4. var port = process.env.VCAP_APP_PORT || 8080;
  5. var nodemailer = require("nodemailer");
  6.  
  7. app.use(express.static(__dirname + '/public'));
  8.  
  9. app.get("/", function (request, response) {
  10. var smtpTransport = nodemailer.createTransport("SMTP",{
  11. host: 'smtp.sendgrid.net',
  12. port: 25,
  13. auth: {
  14. user: "SeNAIsj1mk",
  15. pass: "Btfl3Tifecg92484"
  16. }
  17. });
  18.  
  19. var mail = {
  20. from: "noreply@ibm.com",
  21. to: "svaldarrama@somnio.com",
  22. subject: "Send Email Using Node.js",
  23. text: "Node.js send email test",
  24. html: "<b>Node.js send email test</b>"
  25. };
  26.  
  27. smtpTransport.sendMail(mail, function(error, resp){
  28. if(error){
  29. console.log(error);
  30. response.write(error);
  31. }
  32. else{
  33. console.log("Message sent: " + resp.message);
  34. response.write("Message sent: " + resp.message);
  35. }
  36.  
  37. smtpTransport.close();
  38.  
  39. response.end();
  40. });
  41.  
  42. });
  43.  
  44. app.listen(port);
  45.  
  46. {
  47. "name": "ibm-email-nodejs",
  48. "version": "0.0.1",
  49. "description": "ibm email nodejs",
  50. "main": "app.js",
  51. "scripts": {
  52. "start": "node app.js"
  53. },
  54. "dependencies": {
  55. "express": "~4.x",
  56. "commander": "^2.6.0",
  57. "http-post": "^0.1.1",
  58. "http-proxy": "^1.8.1",
  59. "nodemailer": "0.7.1"
  60. },
  61. "engines": {
  62. "node": "5.9.1",
  63. "npm": "3.7.3"
  64. }
  65. }
  66.  
  67. applications:
  68. - path: .
  69. memory: 512M
  70. instances: 1
  71. domain: mybluemix.net
  72. name: ibm-email-nodejs
  73. host: ibm-email-nodejs
  74. disk_quota: 1024M
  75. command: node app.js
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement