Mailjet을 사용한 사용자 지정 메일 확인

시작하기 전에 이 페이지 위쪽의 정책 유형 선택 선택기를 사용하여 설정하려는 정책 유형을 선택합니다. Azure Active Directory B2C는 사용자가 애플리케이션과 상호 작용하는 방법을 정의하는 두 가지 방법, 즉 미리 정의된 사용자 흐름 또는 완전히 구성 가능한 사용자 지정 정책을 통해 제공합니다. 이 문서에서 필요한 단계는 각 방법마다 다릅니다.

Azure Active Directory B2C(Azure AD B2C)에서 사용자 지정 메일을 사용하여 애플리케이션을 사용하기 위해 등록하는 사용자에게 사용자 지정 메일을 보냅니다. 타사 이메일 공급자인 Mailjet을 사용하면 고유한 이메일 템플릿과 보낸 사람: 주소 및 제목을 사용할 수 있을 뿐만 아니라 현지화 및 사용자 지정 OTP(일회용 암호) 설정을 지원할 수 있습니다.

이 기능은 사용자 지정 정책에만 사용할 수 있습니다. 설정 단계의 경우 이전 선택기의 사용자 지정 정책을 선택합니다.

사용자 지정 메일 확인을 위해서는 Mailjet, SendGrid, SparkPost와 같은 타사 메일 공급자, 사용자 지정 REST API 또는 HTTP 기반 메일 공급자(자체 공급자 포함)를 사용해야 합니다. 이 문서에서는 Mailjet을 사용하는 솔루션 설정 방법을 설명합니다.

Mailjet 계정 만들기

아직 Mailjet 계정이 없는 경우 Mailjet 계정을 설정하여 시작합니다. Azure 고객은 6,000개의 메일(하루 200개 제한)을 잠금 해제할 수 있습니다.

  1. Mailjet 계정 만들기의 설정 지침을 따릅니다.
  2. 메일을 보내려면 보낸 사람 메일 주소나 도메인을 등록하고 유효성을 검사합니다.
  3. API 키 관리 페이지로 이동합니다. 이후 단계에서 사용할 API 키비밀 키를 기록합니다. 두 키는 계정을 만들 때 자동으로 생성됩니다.

Important

Mailjet은 고객에게 공유 IP 및 전용 IP 주소에서 이메일을 보낼 수 있는 기능을 제공합니다. 전용 IP 주소를 사용하는 경우 IP 주소 워밍업으로 자신의 평판을 제대로 구축해야 합니다. 자세한 내용은 IP를 어떻게 워밍업하나요?를 참조하세요.

Azure AD B2C 정책 키 만들기

다음으로 Azure AD B2C 정책 키에 정책이 참조할 Mailjet API 키를 저장합니다.

  1. Azure Portal에 로그인합니다.
  2. 여러 테넌트에 액세스할 수 있는 경우 상단 메뉴의 설정 아이콘을 선택하여 디렉터리 + 구독 메뉴에서 Azure AD B2C 테넌트로 전환합니다.
  3. Azure Portal의 왼쪽 상단 모서리에서 모든 서비스를 선택하고 Azure AD B2C를 검색하여 선택합니다.
  4. 개요 페이지에서 Identity Experience Framework를 선택합니다.
  5. 정책 키, 추가를 차례로 선택합니다.
  6. 옵션에서 수동을 선택합니다.
  7. 정책 키의 이름을 입력합니다. 예: MailjetApiKey. B2C_1A_ 접두사가 키의 이름에 자동으로 추가됩니다.
  8. 비밀에 이전에 기록한 Mailjet API 키를 입력합니다.
  9. 사용으로는 서명을 선택합니다.
  10. 만들기를 실행합니다.
  11. 정책 키, 추가를 차례로 선택합니다.
  12. 옵션에서 수동을 선택합니다.
  13. 정책 키의 이름을 입력합니다. 예: MailjetSecretKey. B2C_1A_ 접두사가 키의 이름에 자동으로 추가됩니다.
  14. 비밀에 이전에 기록한 Mailjet 비밀 키를 입력합니다.
  15. 사용으로는 서명을 선택합니다.
  16. 만들기를 실행합니다.

Mailjet 템플릿 만들기

생성한 Mailjet 계정과 Azure AD B2C 정책 키에 저장된 Mailjet API 키로 Mailjet 동적 트랜잭션 템플릿을 만듭니다.

  1. Mailjet 사이트에서 트랜잭션 템플릿 페이지를 열고 새 템플릿 만들기를 선택합니다.

  2. HTML로 코딩을 선택한 다음 처음부터 코딩을 선택합니다.

  3. Verification email과 같은 고유한 템플릿 이름을 입력한 다음 만들기를 선택합니다.

  4. HTML 편집기에서 다음 HTML 템플릿을 붙여넣거나 사용자 고유의 템플릿을 사용합니다. {{var:otp:""}} 매개 변수와 {{var:email:""}} 매개 변수는 일회성 암호 값 및 사용자 메일 주소로 동적으로 교체됩니다.

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en"><head id="Head1">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>Contoso demo account email verification code</title><meta name="ROBOTS" content="NOINDEX, NOFOLLOW">
       <!-- Template B O365 -->
       <style>
           table td {border-collapse:collapse;margin:0;padding:0;}
       </style>
    </head>
    <body dir="ltr" lang="en">
       <table width="100%" cellpadding="0" cellspacing="0" border="0" dir="ltr" lang="en">
            <tr>
               <td valign="top" width="50%"></td>
               <td valign="top">
                  <!-- Email Header -->
                  <table width="640" cellpadding="0" cellspacing="0" border="0" dir="ltr" lang="en" style="border-left:1px solid #e3e3e3;border-right: 1px solid #e3e3e3;">
                   <tr style="background-color: #0072C6;">
                       <td width="1" style="background:#0072C6; border-top:1px solid #e3e3e3;"></td>
                       <td width="24" style="border-top:1px solid #e3e3e3;border-bottom:1px solid #e3e3e3;">&nbsp;</td>
                       <td width="310" valign="middle" style="border-top:1px solid #e3e3e3; border-bottom:1px solid #e3e3e3;padding:12px 0;">
                           <h1 style="line-height:20pt;font-family:Segoe UI Light; font-size:18pt; color:#ffffff; font-weight:normal;">
                            <span id="HeaderPlaceholder_UserVerificationEmailHeader"><font color="#FFFFFF">Verify your email address</font></span>
                           </h1>
                       </td>
                       <td width="24" style="border-top: 1px solid #e3e3e3;border-bottom: 1px solid #e3e3e3;">&nbsp;</td>
                   </tr>
                  </table>
                  <!-- Email Content -->
                  <table width="640" cellpadding="0" cellspacing="0" border="0" dir="ltr" lang="en">
                   <tr>
                       <td width="1" style="background:#e3e3e3;"></td>
                       <td width="24">&nbsp;</td>
                       <td id="PageBody" width="640" valign="top" colspan="2" style="border-bottom:1px solid #e3e3e3;padding:10px 0 20px;border-bottom-style:hidden;">
                           <table cellpadding="0" cellspacing="0" border="0">
                               <tr>
                                   <td width="630" style="font-size:10pt; line-height:13pt; color:#000;">
                                       <table cellpadding="0" cellspacing="0" border="0" width="100%" style="" dir="ltr" lang="en">
                                           <tr>
                                               <td>
    
       <div style="font-family:'Segoe UI', Tahoma, sans-serif; font-size:14px; color:#333;">
           <span id="BodyPlaceholder_UserVerificationEmailBodySentence1">Thanks for verifying your {{var:email:""}} account!</span>
       </div>
       <br>
       <div style="font-family:'Segoe UI', Tahoma, sans-serif; font-size:14px; color:#333; font-weight: bold">
           <span id="BodyPlaceholder_UserVerificationEmailBodySentence2">Your code is: {{var:otp:""}}</span>
       </div>
       <br>
       <br>
    
                                                   <div style="font-family:'Segoe UI', Tahoma, sans-serif; font-size:14px; color:#333;">
                                                   Sincerely,
                                                   </div>
                                                   <div style="font-family:'Segoe UI', Tahoma, sans-serif; font-size:14px; font-style:italic; color:#333;">
                                                       Contoso
                                                   </div>
                                               </td>
                                           </tr>
                                       </table>
                                   </td>
                               </tr>
                           </table>
    
                       </td>
    
                       <td width="1">&nbsp;</td>
                       <td width="1"></td>
                       <td width="1">&nbsp;</td>
                       <td width="1" valign="top"></td>
                       <td width="29">&nbsp;</td>
                       <td width="1" style="background:#e3e3e3;"></td>
                   </tr>
                   <tr>
                       <td width="1" style="background:#e3e3e3; border-bottom:1px solid #e3e3e3;"></td>
                       <td width="24" style="border-bottom:1px solid #e3e3e3;">&nbsp;</td>
                       <td id="PageFooterContainer" width="585" valign="top" colspan="6" style="border-bottom:1px solid #e3e3e3;padding:0px;">
    
                       </td>
    
                       <td width="29" style="border-bottom:1px solid #e3e3e3;">&nbsp;</td>
                       <td width="1" style="background:#e3e3e3; border-bottom:1px solid #e3e3e3;"></td>
                   </tr>
                  </table>
    
               </td>
               <td valign="top" width="50%"></td>
           </tr>
       </table>
    </body>
    </html>
    
  5. 왼쪽 맨 위에 있는 제목 편집을 확장합니다.

    1. 제목에는 제목의 기본값을 입력합니다. API에 제목 매개 변수가 포함되지 않은 경우 Mailjet은 해당 값을 사용합니다.
    2. 이름에는 회사 이름을 입력합니다.
    3. 주소에는 메일 주소를 선택합니다.
    4. 저장을 선택합니다.
  6. 오른쪽 상단에 있는 저장 및 게시를 선택한 다음 예, 변경 사항을 게시합니다를 선택합니다.

  7. 나중 단계에서 사용할 수 있도록 만든 템플릿의 템플릿 ID를 기록합니다. 클레임 변환을 추가할 때 해당 ID를 지정합니다.

Important

다음 단계에서는 사용자 지정 정책 XML 파일을 빌드하는 방법을 보여 줍니다. GitHub에서 제공되는 샘플 사용자 지정 이메일 확인 사용자 지정 정책을 사용하는 것이 좋습니다. DisplayControl_TrustFrameworkExtensions.xmlTrustFrameworkExtensions.xml을 기본 파일로 사용하므로 정책에 SocialAndLocalAccounts스타터 팩TrustFrameworkBase.xml, TrustFrameworkLocalization.xmlTrustFrameworkExtensions.xml 파일을 포함해야 합니다.

Azure AD B2C 클레임 형식 추가

정책에서 다음 클레임 형식을 <BuildingBlocks> 내의 <ClaimsSchema> 요소에 추가합니다.

해당 클레임 형식은 OTP(일회성 암호) 코드를 사용하여 이메일 주소를 생성 및 확인하는 데 필요합니다.

<!--
<BuildingBlocks>
  <ClaimsSchema> -->
    <ClaimType Id="Otp">
      <DisplayName>Secondary One-time password</DisplayName>
      <DataType>string</DataType>
    </ClaimType>
    <ClaimType Id="emailRequestBody">
      <DisplayName>Mailjet request body</DisplayName>
      <DataType>string</DataType>
    </ClaimType>
    <ClaimType Id="VerificationCode">
      <DisplayName>Secondary Verification Code</DisplayName>
      <DataType>string</DataType>
      <UserHelpText>Enter your email verification code</UserHelpText>
      <UserInputType>TextBox</UserInputType>
    </ClaimType>
  <!-- 
  </ClaimsSchema>
</BuildingBlocks> -->

클레임 변환 추가

다음으로 Mailjet으로 전송된 요청의 본문이 될 JSON 문자열 클레임을 출력하는 클레임 변환이 필요합니다.

JSON 개체의 구조는 InputParameters의 점 표기법의 ID와 InputClaims의 TransformationClaimTypes로 정의됩니다. 점 표기법의 숫자는 배열을 의미합니다. 값은 InputClaims의 값과 InputParameters의 “Value” 속성에서 가져옵니다. JSON 클레임 변환에 대한 자세한 내용은 JSON 클레임 변환을 참조하세요.

<BuildingBlocks> 내에서 <ClaimsTransformations> 요소에 다음 클레임 변환을 추가합니다. 클레임 변환 XML에 다음 사항을 업데이트합니다.

  • Messages.0.TemplateIDInputParameter 값을 앞서 Mailjet 템플릿 만들기에서 만든 Mailjet 트랜잭션 템플릿 ID로 업데이트합니다.
  • Messages.0.From.Email 주소 값을 업데이트합니다. 확인 이메일이 스팸으로 표시되지 않도록 유효한 이메일 주소를 사용합니다.
  • Messages.0.Subject 제목 줄 입력 매개 변수의 값을 조직에 적절한 제목 줄로 업데이트합니다.
<!-- 
<BuildingBlocks>
  <ClaimsTransformations> -->
    <ClaimsTransformation Id="GenerateEmailRequestBody" TransformationMethod="GenerateJson">
      <InputClaims>
        <InputClaim ClaimTypeReferenceId="email" TransformationClaimType="Messages.0.To.0.Email" />
        <InputClaim ClaimTypeReferenceId="otp" TransformationClaimType="Messages.0.Variables.otp" />
        <InputClaim ClaimTypeReferenceId="email" TransformationClaimType="Messages.0.Variables.email" />
      </InputClaims>
      <InputParameters>
        <!-- Update the template_id value with the ID of your Mailjet template. -->
        <InputParameter Id="Messages.0.TemplateID" DataType="int" Value="1234567"/>
        <InputParameter Id="Messages.0.TemplateLanguage" DataType="boolean" Value="true"/>

        <!-- Update with an email appropriate for your organization. -->
        <InputParameter Id="Messages.0.From.Email" DataType="string" Value="my_email@mydomain.com"/>

        <!-- Update with a subject line appropriate for your organization. -->
        <InputParameter Id="Messages.0.Subject" DataType="string" Value="Contoso account email verification code"/>
      </InputParameters>
      <OutputClaims>
        <OutputClaim ClaimTypeReferenceId="emailRequestBody" TransformationClaimType="outputClaim"/>
      </OutputClaims>
    </ClaimsTransformation>
  <!--
  </ClaimsTransformations>
</BuildingBlocks> -->

DataUri 콘텐츠 정의 추가

<BuildingBlocks> 내의 클레임 변환 아래에서 다음 ContentDefinition을 추가하여 버전 2.1.2 데이터 URI를 참조합니다.

<!--
<BuildingBlocks> -->
  <ContentDefinitions>
   <ContentDefinition Id="api.localaccountsignup">
      <DataUri>urn:com:microsoft:aad:b2c:elements:contract:selfasserted:2.1.2</DataUri>
    </ContentDefinition>
    <ContentDefinition Id="api.localaccountpasswordreset">
      <DataUri>urn:com:microsoft:aad:b2c:elements:contract:selfasserted:2.1.2</DataUri>
    </ContentDefinition>
  </ContentDefinitions>
<!--
</BuildingBlocks> -->

DisplayControl 만들기

확인 표시 컨트롤은 사용자에게 전송되는 확인 코드로 이메일 주소를 확인하는 데 사용됩니다.

이 예제 표시 컨트롤은 다음과 같이 구성됩니다.

  1. 사용자로부터 email 주소 클레임 형식을 수집합니다.

  2. SendCode 작업을 사용하여 OTP 코드를 생성하고 OTP 코드가 포함된 이메일을 사용자에게 보냅니다.

    Send verification code email action

  3. 사용자에게 보낸 코드를 사용하여 사용자가 verificationCode 클레임 형식을 제공할 때까지 기다립니다.

  4. 해당 표시 컨트롤에 대한 참조를 포함하는 자체 어설션된 기술 프로필에 email을 반환합니다.

콘텐츠 정의에서 여전히 <BuildingBlocks> 내에 있는 VerificationControl 형식의 다음 DisplayControl을 정책에 추가합니다.

<!--
<BuildingBlocks> -->
  <DisplayControls>
    <DisplayControl Id="emailVerificationControl" UserInterfaceControlType="VerificationControl">
      <DisplayClaims>
        <DisplayClaim ClaimTypeReferenceId="email" Required="true" />
        <DisplayClaim ClaimTypeReferenceId="verificationCode" ControlClaimType="VerificationCode" Required="true" />
      </DisplayClaims>
      <OutputClaims>
        <OutputClaim ClaimTypeReferenceId="email" />
      </OutputClaims>
      <Actions>
        <Action Id="SendCode">
          <ValidationClaimsExchange>
            <ValidationClaimsExchangeTechnicalProfile TechnicalProfileReferenceId="GenerateOtp" />
            <ValidationClaimsExchangeTechnicalProfile TechnicalProfileReferenceId="SendOtp" />
          </ValidationClaimsExchange>
        </Action>
        <Action Id="VerifyCode">
          <ValidationClaimsExchange>
            <ValidationClaimsExchangeTechnicalProfile TechnicalProfileReferenceId="VerifyOtp" />
          </ValidationClaimsExchange>
        </Action>
      </Actions>
    </DisplayControl>
  </DisplayControls>
<!--
</BuildingBlocks> -->

OTP 기술 프로필 추가

GenerateOtp 기술 프로필은 이메일 주소의 코드를 생성합니다. VerifyOtp 기술 프로필은 이메일 주소와 연결된 코드를 확인합니다. 일회성 암호의 형식 구성과 만료를 변경할 수 있습니다. OTP 기술 프로필에 대한 자세한 내용은 일회성 암호 기술 프로필 정의를 참조하세요.

참고 항목

Web.TPEngine.Providers.OneTimePasswordProtocolProvider 프로토콜에 의해 생성된 OTP 코드는 브라우저 세션에 연결됩니다. 즉, 사용자는 각각 해당 세션에 유효한 서로 다른 브라우저 세션에서 고유한 OTP 코드를 생성할 수 있습니다. 반면, 기본 제공 이메일 공급자가 생성한 OTP 코드는 브라우저 세션과 독립적이므로 사용자가 새 브라우저 세션에서 새 OTP 코드를 생성하는 경우 이전 OTP 코드를 대체합니다.

다음 기술 프로필을 <ClaimsProviders> 요소에 추가합니다.

<!--
<ClaimsProviders> -->
  <ClaimsProvider>
    <DisplayName>One time password technical profiles</DisplayName>
    <TechnicalProfiles>
      <TechnicalProfile Id="GenerateOtp">
        <DisplayName>Generate one time password</DisplayName>
        <Protocol Name="Proprietary" Handler="Web.TPEngine.Providers.OneTimePasswordProtocolProvider, Web.TPEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
        <Metadata>
          <Item Key="Operation">GenerateCode</Item>
          <Item Key="CodeExpirationInSeconds">600</Item>
          <Item Key="CodeLength">6</Item>
          <Item Key="CharacterSet">0-9</Item>
          <Item Key="NumRetryAttempts">5</Item>
          <Item Key="NumCodeGenerationAttempts">10</Item>
          <Item Key="ReuseSameCode">false</Item>
        </Metadata>
        <InputClaims>
          <InputClaim ClaimTypeReferenceId="email" PartnerClaimType="identifier" />
        </InputClaims>
        <OutputClaims>
          <OutputClaim ClaimTypeReferenceId="otp" PartnerClaimType="otpGenerated" />
        </OutputClaims>
      </TechnicalProfile>

      <TechnicalProfile Id="VerifyOtp">
        <DisplayName>Verify one time password</DisplayName>
        <Protocol Name="Proprietary" Handler="Web.TPEngine.Providers.OneTimePasswordProtocolProvider, Web.TPEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
        <Metadata>
          <Item Key="Operation">VerifyCode</Item>
        </Metadata>
        <InputClaims>
          <InputClaim ClaimTypeReferenceId="email" PartnerClaimType="identifier" />
          <InputClaim ClaimTypeReferenceId="verificationCode" PartnerClaimType="otpToVerify" />
        </InputClaims>
      </TechnicalProfile>
     </TechnicalProfiles>
  </ClaimsProvider>
<!--
</ClaimsProviders> -->

REST API 기술 프로필 추가

해당 REST API 기술 프로필은 Mailjet 형식을 사용하여 메일 콘텐츠를 생성합니다. RESTful 기술 프로필에 대한 자세한 내용은 RESTful 기술 프로필 정의를 참조하세요.

OTP 기술 프로필과 마찬가지로 다음 기술 프로필을 <ClaimsProviders> 요소에 추가합니다.

<ClaimsProvider>
  <DisplayName>RestfulProvider</DisplayName>
  <TechnicalProfiles>
    <TechnicalProfile Id="sendOtp">
      <DisplayName>Use email API to send the code to the user</DisplayName>
      <Protocol Name="Proprietary" Handler="Web.TPEngine.Providers.RestfulProvider, Web.TPEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
      <Metadata>
        <Item Key="ServiceUrl">https://api.mailjet.com/v3.1/send</Item>
        <Item Key="AuthenticationType">Basic</Item>
        <Item Key="SendClaimsIn">Body</Item>
        <Item Key="ClaimUsedForRequestPayload">emailRequestBody</Item>
      </Metadata>
      <CryptographicKeys>
        <Key Id="BasicAuthenticationUsername" StorageReferenceId="B2C_1A_MailjetApiKey" />
        <Key Id="BasicAuthenticationPassword" StorageReferenceId="B2C_1A_MailjetSecretKey" />
      </CryptographicKeys>
      <InputClaimsTransformations>
        <InputClaimsTransformation ReferenceId="GenerateEmailRequestBody" />
      </InputClaimsTransformations>
      <InputClaims>
        <InputClaim ClaimTypeReferenceId="emailRequestBody" />
      </InputClaims>
    </TechnicalProfile>
  </TechnicalProfiles>
</ClaimsProvider>

DisplayControl에 대한 참조 만들기

마지막 단계로, 앞서 만든 DisplayControl에 대한 참조를 추가합니다. 다음 XML 코드 조각을 사용하여 기본 정책에 구성된 기존 LocalAccountSignUpWithLogonEmailLocalAccountDiscoveryUsingEmailAddress 자체 주장 기술 프로필을 재정의합니다. 이전 버전의 Azure AD B2C 정책을 사용한 경우 이러한 기술 프로필은 DisplayControl에 대한 참조와 함께 DisplayClaims를 사용합니다.

자세한 내용은 자체 어설션된 기술 프로필DisplayControl을 참조하세요.

<ClaimsProvider>
  <DisplayName>Local Account</DisplayName>
  <TechnicalProfiles>
    <TechnicalProfile Id="LocalAccountSignUpWithLogonEmail">
      <DisplayClaims>
        <DisplayClaim DisplayControlReferenceId="emailVerificationControl" />
        <DisplayClaim ClaimTypeReferenceId="displayName" Required="true" />
        <DisplayClaim ClaimTypeReferenceId="givenName" Required="true" />
        <DisplayClaim ClaimTypeReferenceId="surName" Required="true" />
        <DisplayClaim ClaimTypeReferenceId="newPassword" Required="true" />
        <DisplayClaim ClaimTypeReferenceId="reenterPassword" Required="true" />
      </DisplayClaims>
    </TechnicalProfile>
    <TechnicalProfile Id="LocalAccountDiscoveryUsingEmailAddress">
      <DisplayClaims>
        <DisplayClaim DisplayControlReferenceId="emailVerificationControl" />
      </DisplayClaims>
    </TechnicalProfile>
  </TechnicalProfiles>
</ClaimsProvider>

[선택 사항] 메일 지역화

메일을 지역화하려면 Mailjet 또는 메일 공급자에 지역화된 문자열을 보내야 합니다. 예를 들어 메일의 제목, 본문, 코드 메시지 또는 서명을 지역화할 수 있습니다. 이렇게 하려면 GetLocalizedStringsTransformation 클레임 변환을 사용하여 지역화된 문자열을 클레임 형식으로 복사하면 됩니다. JSON 페이로드를 생성하는 GenerateEmailRequestBody 클레임 변환은 지역화된 문자열을 포함하는 입력 클레임을 사용합니다.

  1. 정책에서 subject, message, codeIntro, signature와 같은 문자열 클레임을 정의합니다.

  2. GetLocalizedStringsTransformation 클레임 변환을 정의하여 지역화된 문자열 값을 1단계의 클레임으로 대체합니다.

  3. 다음 XML 코드 조각과 함께 입력 클레임을 사용하도록 GenerateEmailRequestBody 클레임 변환을 변경합니다.

  4. Azure AD B2C에서 지역화할 모든 문자열 대신 동적 매개 변수를 사용하도록 Mailjet 템플릿을 업데이트합니다.

    <ClaimsTransformation Id="GetLocalizedStringsForEmail" TransformationMethod="GetLocalizedStringsTransformation">
      <OutputClaims>
        <OutputClaim ClaimTypeReferenceId="subject" TransformationClaimType="email_subject" />
        <OutputClaim ClaimTypeReferenceId="message" TransformationClaimType="email_message" />
        <OutputClaim ClaimTypeReferenceId="codeIntro" TransformationClaimType="email_code" />
        <OutputClaim ClaimTypeReferenceId="signature" TransformationClaimType="email_signature" />
      </OutputClaims>
    </ClaimsTransformation>
    <ClaimsTransformation Id="GenerateEmailRequestBody" TransformationMethod="GenerateJson">
      <InputClaims>
        <InputClaim ClaimTypeReferenceId="email" TransformationClaimType="Messages.0.To.0.Email" />
        <InputClaim ClaimTypeReferenceId="subject" TransformationClaimType="Messages.0.Subject" />
        <InputClaim ClaimTypeReferenceId="otp" TransformationClaimType="Messages.0.Variables.otp" />
        <InputClaim ClaimTypeReferenceId="email" TransformationClaimType="Messages.0.Variables.email" />
        <InputClaim ClaimTypeReferenceId="message" TransformationClaimType="Messages.0.Variables.otpmessage" />
        <InputClaim ClaimTypeReferenceId="codeIntro" TransformationClaimType="Messages.0.Variables.otpcodeIntro" />
        <InputClaim ClaimTypeReferenceId="signature" TransformationClaimType="Messages.0.Variables.otpsignature" />
      </InputClaims>
      <InputParameters>
        <!-- Update the template_id value with the ID of your Mailjet template. -->
        <InputParameter Id="Messages.0.TemplateID" DataType="int" Value="1234567"/>
        <InputParameter Id="Messages.0.TemplateLanguage" DataType="boolean" Value="true"/>
    
        <!-- Update with an email appropriate for your organization. -->
        <InputParameter Id="Messages.0.From.Email" DataType="string" Value="my_email@mydomain.com"/>
      </InputParameters>
      <OutputClaims>
        <OutputClaim ClaimTypeReferenceId="emailRequestBody" TransformationClaimType="outputClaim"/>
      </OutputClaims>
    </ClaimsTransformation>
    
  5. 다음 지역화 요소를 추가합니다.

    <!--
    <BuildingBlocks> -->
      <Localization Enabled="true">
        <SupportedLanguages DefaultLanguage="en" MergeBehavior="ReplaceAll">
          <SupportedLanguage>en</SupportedLanguage>
          <SupportedLanguage>es</SupportedLanguage>
        </SupportedLanguages>
        <LocalizedResources Id="api.custom-email.en">
          <LocalizedStrings>
            <LocalizedString ElementType="GetLocalizedStringsTransformationClaimType" StringId="email_subject">Contoso account email verification code</LocalizedString>
            <LocalizedString ElementType="GetLocalizedStringsTransformationClaimType" StringId="email_message">Thanks for validating the account</LocalizedString>
            <LocalizedString ElementType="GetLocalizedStringsTransformationClaimType" StringId="email_code">Your code is</LocalizedString>
            <LocalizedString ElementType="GetLocalizedStringsTransformationClaimType" StringId="email_signature">Sincerely</LocalizedString>
          </LocalizedStrings>
        </LocalizedResources>
        <LocalizedResources Id="api.custom-email.es">
          <LocalizedStrings>
            <LocalizedString ElementType="GetLocalizedStringsTransformationClaimType" StringId="email_subject">Código de verificación del correo electrónico de la cuenta de Contoso</LocalizedString>
            <LocalizedString ElementType="GetLocalizedStringsTransformationClaimType" StringId="email_message">Gracias por comprobar la cuenta de </LocalizedString>
            <LocalizedString ElementType="GetLocalizedStringsTransformationClaimType" StringId="email_code">Su código es</LocalizedString>
            <LocalizedString ElementType="GetLocalizedStringsTransformationClaimType" StringId="email_signature">Sinceramente</LocalizedString>
          </LocalizedStrings>
        </LocalizedResources>
      </Localization>
    <!--
    </BuildingBlocks> -->
    
  6. ContentDefinitions 요소를 업데이트하여 LocalizedResources 요소에 대한 참조를 추가합니다.

    <!--
    <BuildingBlocks> -->
      <ContentDefinitions>
        <ContentDefinition Id="api.localaccountsignup">
          <DataUri>urn:com:microsoft:aad:b2c:elements:contract:selfasserted:2.1.2</DataUri>
          <LocalizedResourcesReferences MergeBehavior="Prepend">
            <LocalizedResourcesReference Language="en" LocalizedResourcesReferenceId="api.custom-email.en" />
            <LocalizedResourcesReference Language="es" LocalizedResourcesReferenceId="api.custom-email.es" />
          </LocalizedResourcesReferences>
        </ContentDefinition>
        <ContentDefinition Id="api.localaccountpasswordreset">
          <DataUri>urn:com:microsoft:aad:b2c:elements:contract:selfasserted:2.1.2</DataUri>
          <LocalizedResourcesReferences MergeBehavior="Prepend">
            <LocalizedResourcesReference Language="en" LocalizedResourcesReferenceId="api.custom-email.en" />
            <LocalizedResourcesReference Language="es" LocalizedResourcesReferenceId="api.custom-email.es" />
          </LocalizedResourcesReferences>
        </ContentDefinition>
      </ContentDefinitions>
    <!--
    </BuildingBlocks> -->
    
  7. 마지막으로 다음 입력 클레임 변환을 LocalAccountSignUpWithLogonEmailLocalAccountDiscoveryUsingEmailAddress 기술 프로필에 추가합니다.

    <InputClaimsTransformations>
      <InputClaimsTransformation ReferenceId="GetLocalizedStringsForEmail" />
    </InputClaimsTransformations>
    

[선택 사항] UI 지역화

Localization 요소를 사용하면 사용자 경험용 정책에서 여러 로캘이나 언어를 지원할 수 있습니다. 정책의 지역화 지원을 통해 확인 표시 컨트롤 사용자 인터페이스 요소일회성 암호 오류 메시지에 대해 언어별 문자열을 제공할 수 있습니다. 다음 LocalizedString을 LocalizedResources에 추가합니다.

<LocalizedResources Id="api.custom-email.en">
  <LocalizedStrings>
    ...
    <!-- Display control UI elements-->
    <LocalizedString ElementType="DisplayControl" ElementId="emailVerificationControl" StringId="intro_msg">Verification is necessary. Please click Send button.</LocalizedString>
    <LocalizedString ElementType="DisplayControl" ElementId="emailVerificationControl" StringId="success_send_code_msg">Verification code has been sent to your inbox. Please copy it to the input box below.</LocalizedString>
    <LocalizedString ElementType="DisplayControl" ElementId="emailVerificationControl" StringId="failure_send_code_msg">We are having trouble verifying your email address. Please enter a valid email address and try again.</LocalizedString>
    <LocalizedString ElementType="DisplayControl" ElementId="emailVerificationControl" StringId="success_verify_code_msg">E-mail address verified. You can now continue.</LocalizedString>
    <LocalizedString ElementType="DisplayControl" ElementId="emailVerificationControl" StringId="failure_verify_code_msg">We are having trouble verifying your email address. Please try again.</LocalizedString>
    <LocalizedString ElementType="DisplayControl" ElementId="emailVerificationControl" StringId="but_send_code">Send verification code</LocalizedString>
    <LocalizedString ElementType="DisplayControl" ElementId="emailVerificationControl" StringId="but_verify_code">Verify code</LocalizedString>
    <LocalizedString ElementType="DisplayControl" ElementId="emailVerificationControl" StringId="but_send_new_code">Send new code</LocalizedString>
    <LocalizedString ElementType="DisplayControl" ElementId="emailVerificationControl" StringId="but_change_claims">Change e-mail</LocalizedString>
    <!-- Claims-->
    <LocalizedString ElementType="ClaimType" ElementId="emailVerificationCode" StringId="DisplayName">Verification Code</LocalizedString>
    <LocalizedString ElementType="ClaimType" ElementId="emailVerificationCode" StringId="UserHelpText">Verification code received in the email.</LocalizedString>
    <LocalizedString ElementType="ClaimType" ElementId="emailVerificationCode" StringId="AdminHelpText">Verification code received in the email.</LocalizedString>
    <LocalizedString ElementType="ClaimType" ElementId="email" StringId="DisplayName">Email</LocalizedString>
    <!-- Email validation error messages-->
    <LocalizedString ElementType="ErrorMessage" StringId="UserMessageIfSessionDoesNotExist">You have exceeded the maximum time allowed.</LocalizedString>
    <LocalizedString ElementType="ErrorMessage" StringId="UserMessageIfMaxRetryAttempted">You have exceeded the number of retries allowed.</LocalizedString>
    <LocalizedString ElementType="ErrorMessage" StringId="UserMessageIfMaxNumberOfCodeGenerated">You have exceeded the number of code generation attempts allowed.</LocalizedString>
    <LocalizedString ElementType="ErrorMessage" StringId="UserMessageIfInvalidCode">You have entered the wrong code.</LocalizedString>
    <LocalizedString ElementType="ErrorMessage" StringId="UserMessageIfSessionConflict">Cannot verify the code, please try again later.</LocalizedString>
    <LocalizedString ElementType="ErrorMessage" StringId="UserMessageIfVerificationFailedRetryAllowed">The verification has failed, please try again.</LocalizedString>
  </LocalizedStrings>
</LocalizedResources>

다음 단계