コンテンツにスキップ

メールワーカーの編集

メールワーカーの追加や編集は簡単です。メールワーカーの名前を変更したり、削除したり、編集したり、特定のメールワーカーにバインドされたルートを変更したりできます。

メールワーカーを追加する

  1. Cloudflareダッシュボードにログインし、アカウントとドメインを選択します。

  2. Email > Email Routing > Email Workersに移動します。

  3. Createを選択します。

  1. (Optional) Enter a descriptive Email Worker name in Create a worker name.

  2. In Select a starter, select the starter template that best suits your needs. You can also start from scratch and build your own Email Worker with Create my own. After choosing your template, select Create.

  3. Now, configure your code on the left side of the screen. For example, if you are creating an Email Worker from the Allowlist template:

    1. In const allow = ["friend@example.com", "coworker@example.com"]; replace the email examples with the addresses you want to allow emails from.
    2. In await message.forward("inbox@corp"); replace the email address example with the address where emails should be forwarded to.
  4. (Optional) You can test your logic on the right side of the screen. In the From field, enter either an email address from your approved senders list or one that is not on the approved list. When you select Trigger email event you should see a message telling you if the email address is allowed or rejected.

  5. Select Save and deploy to save your Email Worker when you are finished.

  6. Select the arrow next to the name of your Email Worker to go back to the main screen.

  7. Find the Email Worker you have just created, and select Create route. This binds the Email Worker to a route (or email address) you can share. All emails received in this route will be forwarded to and processed by the Email Worker.

  1. Select Save to finish setting up your Email Worker.

You have successfully created your Email Worker. In the Email Worker’s card, select the route field to expand it and check the routes associated with the Worker.

メールワーカーを編集する

  1. Cloudflareダッシュボードにログインし、アカウントとドメインを選択します。

  2. Email > Email Routing > Email Workersに移動します。

  3. 名前を変更したいメールワーカーを見つけ、その隣の三点ボタンを選択します。

  4. Code editorを選択します。

  5. コードに適切な変更を加えます。

  6. 編集が完了したら、Save and deployを選択します。

メールワーカーの名前を変更する

メールワーカーの名前を変更すると、以前にバインドされていたルートが失われます。メールワーカーの名前を変更した後、ルートを再設定する必要があります。

  1. Cloudflareダッシュボードにログインし、アカウントとドメインを選択します。

  2. Email > Email Routing > Email workersに移動します。

  3. 名前を変更したいメールワーカーを見つけ、その隣の三点ボタンを選択します。

  4. ドロップダウンメニューからManage Workerを選択します。

  5. Manage Service > Rename serviceを選択し、新しいメールワーカーの名前を入力します。

  6. Continue > Moveを選択します。

  7. 警告を確認し、Finishを選択します。

  8. 次に、Email > Email Routingに戻ります。

  9. Routesで、以前にメールワーカーに関連付けていたカスタムアドレスを見つけ、Editを選択します。

  10. Destinationのドロップダウンメニューから、名前を変更したメールワーカーを選択します。

  11. Saveを選択します。

ルートを編集する

以下の手順では、メールワーカーに関連付けられたルートを変更する方法を示します。

  1. Cloudflareダッシュボードにログインし、アカウントとドメインを選択します。

  2. Email > Email Routing > Email workersに移動します。

  3. 関連付けられたルートを変更したいメールワーカーを見つけ、そのカードのrouteを選択します。

  4. Editを選択して必要な変更を加えます。

  5. Saveを選択して完了します。

メールワーカーを削除する

  1. Cloudflareダッシュボードにログインし、アカウントとドメインを選択します。

  2. Email > Email Routing > Email workersに移動します。

  3. 削除したいメールワーカーを見つけ、その隣の三点ボタンを選択します。

  4. ドロップダウンメニューからManage Workerを選択します。

  5. Manage Service > Deleteを選択します。

  6. 削除を確認するためにメールワーカーの名前を入力し、Deleteを選択します。