Name:
interface
Value:
Amplify has re-imagined the way frontend developers build fullstack applications. Develop and deploy without the hassle.
Gen1 DocsLegacy

Page updated Aug 16, 2024

メールのカスタマイズ

確認メールのカスタマイズ

デフォルトでは、Amplify Auth リソースはメールをデフォルトの方法としてスカッフォールドされます。ユーザーがサインアップすると、サインアップ時に指定したメールアドレスの所有権を確認するための確認メールが届きます。確認メールなどのメールはアプリのブランド ID でカスタマイズできます。

開始するには、loginWithemail 属性を true からオブジェクトに変更して、デフォルトの動作のカスタマイズを開始します:

amplify/auth/resource.ts
import { defineAuth } from "@aws-amplify/backend"
export const auth = defineAuth({
loginWith: {
- email: true,
+ email: {
+ verificationEmailStyle: "CODE",
+ verificationEmailSubject: "Welcome to my app!",
+ verificationEmailBody: (createCode) => `Use this code to confirm your account: ${createCode()}`,
+ },
},
})

招待メールのカスタマイズ

場合によっては、Amplify コンソールでユーザーの代わりにユーザーアカウントをセットアップできます。この場合、Amplify Auth はユーザーをアプリケーションへようこそというウェルカムメールを送信します。このメールには、簡単なウェルカムメッセージと、ログイン時に使用できるメールアドレス、およびセットアップした一時的なパスワードが含まれています。

そのメールをカスタマイズする場合は、email オブジェクトの userInvitation 属性をオーバーライドできます:

amplify/auth/resource.ts
import { defineAuth } from "@aws-amplify/backend"
export const auth = defineAuth({
loginWith: {
- email: true,
+ email: {
+ // can be used in conjunction with a customized welcome email as well
+ verificationEmailStyle: "CODE",
+ verificationEmailSubject: "Welcome to my app!",
+ verificationEmailBody: (createCode) => `Use this code to confirm your account: ${createCode()}`,
+ userInvitation: {
+ emailSubject: "Welcome to my app!",
+ emailBody: (user, code) =>
+ `We're happy to have you! You can now login with username ${user()} and temporary password ${code()}`,
+ },
+ },
},
})

emailBody 関数の usercode 引数を使用する場合、usercode関数であり、呼び出す必要があることに注意してください。呼び出さないと、サンドボックスのデプロイ時にエラーが発生します。