Herokuの解析サーバアプリケーション用にmailgunを設定しようとしています。Heroku上でparse-serverを使用してmailgunを設定する
推奨APIは
https://github.com/ParsePlatform/parse-server-simple-mailgun-adapter
しかし、実際にこれが非存在していない達成する方法の説明です。
--------- EDIT -----------
続く命令とサーバがHerokuのにプッシュします。私はまだメールを受け取っていませんが。私はちょうどmailgunのサンドボックスを使用し、受信者を承認して起動しました。テンプレートへのパスを指定するかについて
イムわからない:
fromAddress: process.env.EMAIL_FROM
これはので、私はちょうど
明らかこれはイマイチ有効[email protected]入力したmailgunによって提供されていませんでしたか?
index.jsコード:
var express = require('express');
var ParseServer = require('parse-server').ParseServer;
var S3Adapter = require('parse-server').S3Adapter;
var path = require('path');
const resolve = require('path').resolve;
var databaseUri = process.env.DATABASE_URI || process.env.MONGODB_URI;
if (!databaseUri) {
console.log('DATABASE_URI not specified, falling back to localhost.');
}
var api = new ParseServer({
//**** General Settings ****//
databaseURI: databaseUri || 'mongodb://localhost:27017/dev',
cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
serverURL: process.env.SERVER_URL || 'http://localhost:1337/parse', // Don't forget to change to https if needed
maxUploadSize: '500mb',
//**** Security Settings ****//
// allowClientClassCreation: process.env.CLIENT_CLASS_CREATION || false,
appId: process.env.APP_ID || 'myAppId',
masterKey: process.env.MASTER_KEY || 'myMasterKey', //Add your master key here. Keep it secret!
//**** Live Query ****//
// liveQuery: {
// classNames: ["TestObject", "Place", "Team", "Player", "ChatMessage"] // List of classes to support for query subscriptions
// },
//**** File Storage ****//
filesAdapter: new S3Adapter({
accessKey: process.env.S3_ACCESS_KEY || '',
secretKey: process.env.S3_SECRET_KEY || '',
bucket: process.env.S3_BUCKET || '',
directAccess: true
}),
//**** Email Verification ****//
/* Enable email verification */
// verifyUserEmails: true,
/* The public URL of your app */
// This will appear in the link that is used to verify email addresses and reset passwords.
publicServerURL: process.env.SERVER_URL || '',
appName: process.env.APP_NAME || '',
emailAdapter: {
module: 'parse-server-mailgun',
options: {
fromAddress: process.env.EMAIL_FROM || '',
domain: process.env.MAILGUN_DOMAIN || '',
apiKey: process.env.MAILGUN_API_KEY || '',
templates: {
passwordResetEmail: {
subject: 'Reset your password',
pathPlainText: resolve(__dirname, 'https:/myparseserveronheroku.herokuapp.com/node_modules/parse-server-mailgun-adapter/test/email-templates/password_reset_email.txt'),
pathHtml: resolve(__dirname, 'https:/myparseserveronheroku.herokuapp.com/node_modules/parse-server-mailgun-adapter/test/email-templates/password_reset_email.html'),
callback: (user) => { return { firstName: user.get('firstName') }}
// Now you can use {{firstName}} in your templates
},
verificationEmail: {
subject: 'Confirm your account',
pathPlainText: resolve(__dirname, 'https:/myparseserveronheroku.herokuapp.com/node_modules/parse-server-mailgun-adapter/test/email-templates/verification_email.txt'),
pathHtml: resolve(__dirname, 'https:/myparseserveronheroku.herokuapp.com/node_modules/parse-server-mailgun-adapter/test/email-templates/verification_email.html'),
callback: (user) => { return { firstName: user.get('firstName') }}
// Now you can use {{firstName}} in your templates
}
}
}
}
});
パスワードのリセットを送信するために私のSWIFTコードは、メッセージが送信されたことを言うので、私はクリフは私に言ったすべてが正しいと仮定して、サーバー側がOKに設定されていますおそらくちょうど私が変数でやったばかげたばかげたものです。
PFUser.requestPasswordResetForEmail(inBackground: emailAddress!) { (success, error) in
if error != nil {
// display error message
let userMessage: String = error!.localizedDescription
GeneralFunctions.createAlert(errorTitle: "Oops...", errorMessage: userMessage, className: self)
} else {
// display success message
let userMessage: String = "An new password was sent to \(emailAddress!)"
GeneralFunctions.createAlert(errorTitle: "Hooray...", errorMessage: userMessage, className: self)
}
}
----------- EDIT ----------
詳細ログ
[email protected]
2017-02-06T00:44:25.788619+00:00 app[web.1]: [36mverbose[39m: RESPONSE from [POST] /parse/requestPasswordReset: {
2017-02-06T00:44:25.788623+00:00 app[web.1]: "response": {}
2017-02-06T00:44:25.788625+00:00 app[web.1]: }
2017-02-06T00:44:25.797455+00:00 app[web.1]: { Error: ENOENT: no such file or directory, open '/app/https:/myparseserveronheroku.herokuapp.com/node_modules/parse-server-mailgun-adapter/test/email-templates/password_reset_email.txt'
2017-02-06T00:44:25.797458+00:00 app[web.1]: errno: -2,
2017-02-06T00:44:25.797459+00:00 app[web.1]: code: 'ENOENT',
2017-02-06T00:44:25.797459+00:00 app[web.1]: syscall: 'open',
2017-02-06T00:44:25.797462+00:00 app[web.1]: path: '/app/https:/myparseserveronheroku.herokuapp.com/node_modules/parse-server-mailgun-adapter/test/email-templates/password_reset_email.txt' }
2017-02-06T00:44:25.792191+00:00 heroku[router]: at=info method=POST path="/parse/requestPasswordReset" host=myparseserveronheroku.herokuapp.com request_id=666ff3e0-db4a-4e76-b7b5-6353edc7e15a fwd="111.111.111.11" dyno=web.1 connect=0ms service=81ms status=200 bytes=483
リセットパスワードをしようとするので、間違いのように見えた後、存在しないテンプレートから送信しようとしています。ここでパスを指定する方法がわからないのですが、node_modules/parse-server-mailgun-adapter/test/email-templatesを含むすべてのディレクトリがHerokuにプッシュされていると思っていました。
感謝。私はこれでどうやってどうなるのか教えてあげるよ! – Pippo
用意されているテンプレートを使用するつもりでしたが、どのようにこれらのパスを指定しますか?/parse-server/node_modules/parse-server-mailgun/test – Pippo
あなたの設定は正しいので、良いです。パスが正しくありません。 __dirnameは、現在のモジュールのディレクトリ名です。したがって、index.jsがどのパスにあるかを見て、そこからパスを構築してください。httpsやドメイン名はありません。真のパス – Cliffordwh