mirror of
https://github.com/strapi/strapi.git
synced 2025-12-27 07:03:38 +00:00
sanatize email options
Signed-off-by: Pierre Noël <petersg83@gmail.com>
This commit is contained in:
parent
8821f42694
commit
bc3cee4c54
1
examples/getstarted/.gitignore
vendored
1
examples/getstarted/.gitignore
vendored
@ -82,6 +82,7 @@ ssl
|
||||
nbproject
|
||||
public/uploads/*
|
||||
!public/uploads/.gitkeep
|
||||
.env
|
||||
|
||||
############################
|
||||
# Node.js
|
||||
|
||||
@ -1,12 +1,16 @@
|
||||
module.exports = {
|
||||
module.exports = ({ env }) => ({
|
||||
graphql: {
|
||||
amountLimit: 5,
|
||||
depthLimit: 10,
|
||||
},
|
||||
email: {
|
||||
provider: 'sendmail',
|
||||
provider: 'mailgun',
|
||||
providerOptions: {
|
||||
apiKey: env('MAILGUN_API_KEY'),
|
||||
domain: env('MAILGUN_DOMAIN'),
|
||||
},
|
||||
settings: {
|
||||
defaultFrom: 'strapi@strapi.io',
|
||||
},
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
@ -27,7 +27,7 @@
|
||||
"strapi-plugin-graphql": "3.0.0-beta.20.3",
|
||||
"strapi-plugin-upload": "3.0.0-beta.20.3",
|
||||
"strapi-plugin-users-permissions": "3.0.0-beta.20.3",
|
||||
"strapi-provider-email-sendmail": "3.0.0-beta.20.3",
|
||||
"strapi-provider-email-mailgun": "3.0.0-beta.20.3",
|
||||
"strapi-provider-upload-aws-s3": "3.0.0-beta.20.3",
|
||||
"strapi-provider-upload-cloudinary": "3.0.0-beta.20.3",
|
||||
"strapi-utils": "3.0.0-beta.20.3"
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const nodeSES = require('node-ses');
|
||||
const _ = require('lodash');
|
||||
|
||||
module.exports = {
|
||||
init: (providerOptions = {}, settings = {}) => {
|
||||
@ -23,6 +24,8 @@ module.exports = {
|
||||
...rest,
|
||||
};
|
||||
|
||||
msg = _.pickBy(msg, value => typeof value !== 'undefined');
|
||||
|
||||
client.sendEmail(msg, function(err) {
|
||||
if (err) {
|
||||
reject([{ messages: [{ id: 'Auth.form.error.email.invalid' }] }]);
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const mailgunFactory = require('mailgun-js');
|
||||
const _ = require('lodash');
|
||||
|
||||
module.exports = {
|
||||
init: (providerOptions = {}, settings = {}) => {
|
||||
@ -26,6 +27,8 @@ module.exports = {
|
||||
...rest,
|
||||
};
|
||||
|
||||
msg = _.pickBy(msg, value => typeof value !== 'undefined');
|
||||
|
||||
mailgun.messages().send(msg, function(err) {
|
||||
if (err) {
|
||||
reject([{ messages: [{ id: 'Auth.form.error.email.invalid' }] }]);
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const sendgrid = require('@sendgrid/mail');
|
||||
const _ = require('lodash');
|
||||
|
||||
module.exports = {
|
||||
init: (providerOptions = {}, settings = {}) => {
|
||||
@ -23,6 +24,8 @@ module.exports = {
|
||||
...rest,
|
||||
};
|
||||
|
||||
msg = _.pickBy(msg, value => typeof value !== 'undefined');
|
||||
|
||||
sendgrid.send(msg, function(err) {
|
||||
if (err) {
|
||||
reject([{ messages: [{ id: 'Auth.form.error.email.invalid' }] }]);
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const sendmailFactory = require('sendmail');
|
||||
const _ = require('lodash');
|
||||
|
||||
module.exports = {
|
||||
init: (providerOptions = {}, settings = {}) => {
|
||||
@ -13,26 +14,27 @@ module.exports = {
|
||||
return new Promise((resolve, reject) => {
|
||||
const { from, to, cc, bcc, replyTo, subject, text, html, ...rest } = options;
|
||||
|
||||
sendmail(
|
||||
{
|
||||
from: from || settings.defaultFrom,
|
||||
to,
|
||||
cc,
|
||||
bcc,
|
||||
replyTo: replyTo || settings.defaultReplyTo,
|
||||
subject,
|
||||
text,
|
||||
html,
|
||||
...rest,
|
||||
},
|
||||
function(err) {
|
||||
if (err) {
|
||||
reject([{ messages: [{ id: 'Auth.form.error.email.invalid' }] }]);
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
let msg = {
|
||||
from: from || settings.defaultFrom,
|
||||
to,
|
||||
cc,
|
||||
bcc,
|
||||
replyTo: replyTo || settings.defaultReplyTo,
|
||||
subject,
|
||||
text,
|
||||
html,
|
||||
...rest,
|
||||
};
|
||||
|
||||
msg = _.pickBy(msg, value => typeof value !== 'undefined');
|
||||
|
||||
sendmail(msg, err => {
|
||||
if (err) {
|
||||
reject([{ messages: [{ id: 'Auth.form.error.email.invalid' }] }]);
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user