首先,我在AWS Elastic Beanstalk上运行Parse Server。
我在自述文件中看到了这个文档
##### Email verification and password reset
Verifying user email addresses and enabling password reset via email requries an email adapter. As part of the `parse-server` package we provide an adapter for sending email through Mailgun. To use it, sign up for Mailgun, and add this to your initialization code:
```js
var server = ParseServer({
...otherOptions,
// Enable email verification
verifyUserEmails: true,
// set preventLoginWithUnverifiedEmail to false to allow user to login without verifying their email
// set preventLoginWithUnverifiedEmail to true to prevent user from login if their email is not verified
preventLoginWithUnverifiedEmail: false, // defaults to false
// The public URL of your app.
// This will appear in the link that is used to verify email addresses and reset passwords.
// Set the mount path as it is in serverURL
publicServerURL: 'https://example.com/parse',
// Your apps name. This will appear in the subject and body of the emails that are sent.
appName: 'Parse App',
// The email adapter
emailAdapter: {
module: 'parse-server-simple-mailgun-adapter',
options: {
// The address that your emails come from
fromAddress: 'parse@example.com',
// Your domain from mailgun.com
domain: 'example.com',
// Your API key from mailgun.com
apiKey: 'key-mykey',
}
}
});
但这对我来说并不足够。我没有使用现有的快递网站,我需要知道在存储库中添加mailgun代码的位置。
我已经有了mailgun并在php中使用过它,我明确地使用它来重置用户密码。
所以,我的解析服务器文件夹中的哪个文件需要添加mailgun适配器? 这是我的文件结构。如果我不清楚,请告诉我......
这就是我现在所处的位置。这是对的吗?我的邮件信誉尚未存在,但我知道这样做。
class ParseServer {
constructor({
appId = requiredParameter('You must provide an appId!'),
masterKey = requiredParameter('You must provide a masterKey!'),
appName,
filesAdapter,
push,
loggerAdapter,
logsFolder,
databaseURI,
databaseOptions,
databaseAdapter,
cloud,
collectionPrefix = '',
clientKey,
javascriptKey,
dotNetKey,
restAPIKey,
webhookKey,
fileKey = undefined,
facebookAppIds = [],
enableAnonymousUsers = true,
allowClientClassCreation = true,
oauth = {},
serverURL = requiredParameter('You must provide a serverURL!'),
maxUploadSize = '20mb',
verifyUserEmails = true,
preventLoginWithUnverifiedEmail = false,
cacheAdapter,
emailAdapter: {
module: 'parse-server-simple-mailgun-adapter',
options: {
// The address that your emails come from
fromAddress: 'parse@example.com',
// Your domain from mailgun.com
domain: 'example.com',
// Your API key from mailgun.com
apiKey: 'key-mykey',
}
},
publicServerURL,
customPages = {
invalidLink: undefined,
verifyEmailSuccess: undefined,
choosePassword: undefined,
passwordResetSuccess: undefined
},
答案 0 :(得分:1)
parse-server默认包含mailgun-js模块,因此您可以在没有任何依赖性的情况下使用它。您需要做的是使用它:
请注意,您在上面添加的适配器仅用于电子邮件验证和密码重置。如果您希望能够发送电子邮件(例如营销电子邮件,订婚等),您可以在那里创建一个云代码功能,您需要使用mailgun-js模块并使用mailgun-js模块发送电子邮件,就像它在here中描述 然后,从您的客户端代码中,您将需要触发此云代码功能,并将发送电子邮件。