mail.js 612 B

12345678910111213141516171819202122232425262728
  1. const config = require('../config');
  2. const nodemailer = require('nodemailer');
  3. let mailConfig = {};
  4. if (process.env.NODE_ENV === 'production') {
  5. mailConfig = {
  6. host: config.MAIL_HOST,
  7. port: config.MAIL_PORT,
  8. secure: config.MAIL_SECURE,
  9. auth: {
  10. user: config.MAIL_USER,
  11. pass: config.MAIL_PASSWORD,
  12. },
  13. };
  14. } else {
  15. mailConfig = {
  16. host: 'smtp.ethereal.email',
  17. port: 587,
  18. auth: {
  19. user: 'likyqc3fcjtgdnfd@ethereal.email',
  20. pass: 'fjmhsR8zJQZ3BKQath',
  21. },
  22. };
  23. }
  24. const transporter = nodemailer.createTransport(mailConfig);
  25. module.exports = transporter;