-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #54 from marcelooblan2016/develop
Develop
- Loading branch information
Showing
18 changed files
with
226 additions
and
27 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const constants_1 = __importDefault(require("../constants")); | ||
const nodemailer_1 = __importDefault(require("nodemailer")); | ||
class Mailer { | ||
constructor(options) { | ||
this.transporter = nodemailer_1.default.createTransport({ | ||
host: constants_1.default.mailer.host, | ||
port: constants_1.default.mailer.port, | ||
secure: constants_1.default.mailer.secure, | ||
auth: { | ||
user: constants_1.default.mailer.auth.user, | ||
pass: constants_1.default.mailer.auth.pass, | ||
}, | ||
}); | ||
} | ||
send(params) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
try { | ||
if (constants_1.default.mailer.auth.user == null || constants_1.default.mailer.auth.pass == null) { | ||
throw "mail set up not ready."; | ||
} | ||
let info = yield this.transporter.sendMail({ | ||
from: constants_1.default.mailer.from, | ||
to: constants_1.default.mailer.to, | ||
subject: params.subject, | ||
text: params.message, // plain text body | ||
}); | ||
console.log("Message sent: %s", info.messageId); | ||
return true; | ||
} | ||
catch (error) { } | ||
return false; | ||
}); | ||
} | ||
} | ||
exports.default = new Mailer; |
This file contains 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
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
declare module "nodemailer" |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import C from '../constants' | ||
import nodemailer from 'nodemailer'; | ||
|
||
class Mailer { | ||
protected transporter: any; | ||
|
||
constructor(options? : any) { | ||
this.transporter = nodemailer.createTransport({ | ||
host: C.mailer.host, | ||
port: C.mailer.port, | ||
secure: C.mailer.secure, | ||
auth: { | ||
user: C.mailer.auth.user, | ||
pass: C.mailer.auth.pass, | ||
}, | ||
}); | ||
} | ||
|
||
public async send(params: RecordMailer.sendParams): Promise<boolean> { | ||
try { | ||
if (C.mailer.auth.user == null || C.mailer.auth.pass == null) { | ||
throw "mail set up not ready."; | ||
} | ||
|
||
let info = await this.transporter.sendMail({ | ||
from: C.mailer.from, // sender address | ||
to: C.mailer.to, // list of receivers | ||
subject: params.subject, // Subject line | ||
text: params.message, // plain text body | ||
}); | ||
|
||
console.log("Message sent: %s", info.messageId); | ||
|
||
return true; | ||
|
||
} catch (error) {} | ||
|
||
return false; | ||
} | ||
} | ||
|
||
export default new Mailer; |
Oops, something went wrong.