Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(connect): add possibility to connect with login and password (ie… #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@ var _sendgrid2 = _interopRequireDefault(_sendgrid);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var SimpleSendGridAdapter = function SimpleSendGridAdapter(mailOptions) {
if (!mailOptions || !mailOptions.apiKey || !mailOptions.fromAddress) {
throw 'SimpleSendGridAdapter requires an API Key.';
if (!mailOptions || !mailOptions.apiKey && !mailOptions.username && !mailOptions.password) {
throw 'SimpleSendGridAdapter requires an apiKey or username / password';
}
var sendgrid = (0, _sendgrid2.default)(mailOptions.apiKey);
if (!mailOptions.fromAddress) {
throw 'SimpleSendGridAdapter requires fromAddress';
}
var sendgrid = mailOptions.apiKey ? (0, _sendgrid2.default)(mailOptions.apiKey) : (0, _sendgrid2.default)(mailOptions.username, mailOptions.password);

var sendMail = function sendMail(_ref) {
var to = _ref.to;
Expand Down
9 changes: 6 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import SendGrid from 'sendgrid';

let SimpleSendGridAdapter = mailOptions => {
if (!mailOptions || !mailOptions.apiKey || !mailOptions.fromAddress) {
throw 'SimpleSendGridAdapter requires an API Key.';
if (!mailOptions || (!mailOptions.apiKey && !mailOptions.username && !mailOptions.password)){
throw 'SimpleSendGridAdapter requires an apiKey or username / password';
}
let sendgrid = SendGrid(mailOptions.apiKey);
if (!mailOptions.fromAddress){
throw 'SimpleSendGridAdapter requires fromAddress';
}
let sendgrid = (mailOptions.apiKey ? SendGrid(mailOptions.apiKey) : SendGrid(mailOptions.username, mailOptions.password));

let sendMail = ({to, subject, text}) => {
return new Promise((resolve, reject) => {
Expand Down