Guest User

Untitled

a guest
Feb 26th, 2018
324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. import * as nodemailer from "nodemailer";
  2. import config from '../configs/configs';
  3.  
  4. class Mail {
  5.  
  6. constructor(
  7. public to?: string,
  8. public subject?: string,
  9. public message?: string) { }
  10.  
  11.  
  12. sendMail() {
  13.  
  14. let mailOptions = {
  15. from: "portalband@band.com.br",
  16. to: this.to,
  17. subject: this.subject,
  18. html: this.message
  19. };
  20.  
  21. const transporter = nodemailer.createTransport({
  22. host: config.host,
  23. port: config.port,
  24. secure: false,
  25. auth: {
  26. user: config.user,
  27. pass: config.password
  28. },
  29. tls: { rejectUnauthorized: false }
  30. });
  31.  
  32.  
  33. console.log(mailOptions);
  34.  
  35. transporter.sendMail(mailOptions, function (error, info) {
  36. if (error) {
  37. return error;
  38. } else {
  39. return "E-mail enviado com sucesso!";
  40. }
  41. });
  42. }
  43.  
  44.  
  45. }
  46.  
  47. export default new Mail;
Add Comment
Please, Sign In to add comment