# Amazon SES を使用した SMTP 認証情報でのメール送信は機能しますが、Discourse からは機能しません

**URL:** https://meta.discourse.org/t/sending-emails-with-smtp-credentials-using-amazon-ses-works-but-not-from-discourse/233795
**Category:** Self-hosting
**Tags:** email
**Created:** [2022 年 7 月 24 日午前 11:31 UTC](https://meta.discourse.org/t/sending-emails-with-smtp-credentials-using-amazon-ses-works-but-not-from-discourse/233795 "2022-07-24T11:31:32Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [2022 年 7 月 24 日午前 11:31 UTC](https://meta.discourse.org/t/sending-emails-with-smtp-credentials-using-amazon-ses-works-but-not-from-discourse/233795/1 "2022-07-24T11:31:32Z")

</div>

Amazon SES を設定しました。  
サンドボックスから出たので、未確認のアドレスにもメールを送信できます。  
[Amazon SES のドキュメント](https://docs.aws.amazon.com/ses/latest/dg/request-production-access.html)より：

> アカウントがサンドボックスから出ると、受信者のアドレスまたはドメインが確認済みかどうかに関係なく、任意の受信者にメールを送信できます。ただし、「From」、「Source」、「Sender」、「Return-Path」アドレスとして使用するすべての ID を確認する必要があります。

SMTP 認証情報も設定しました。

サンドボックス外の受信者にテストメールを送信することは、Amazon S3 ダッシュボードやその他の SMTP テストツールから機能します。  
しかし、Discourse からは機能しません。

`app.yml`：

```yml
  DISCOURSE_SMTP_ADDRESS: email-smtp.eu-west-3.amazonaws.com
  DISCOURSE_SMTP_PORT: 587
  DISCOURSE_SMTP_USER_NAME: AKIA ****************
  DISCOURSE_SMTP_PASSWORD: " *************************************"
  #DISCOURSE_SMTP_ENABLE_START_TLS: true # (optional, default true)
  DISCOURSE_SMTP_DOMAIN: forum.monocycle.info # (address to send notifications from)
  DISCOURSE_NOTIFICATION_EMAIL: noreply@forum.monocycle.info # (address to send notifications from)

```

メールでの返信設定：

 ![image](https://global.discourse-cdn.com/meta/original/4X/e/1/a/e1ae6ea757b29f9e3e6093ee39ab3fce46148e90.png)

Discourse からテストメールを送信すると、次のエラーメッセージが表示されてメールがスキップされます。

> 554 Message rejected: Email address is not verified. The following identities failed the check in region EU-WEST-3: `monocycle.info+verp-3a76559e11c2b9a318165af8eb968f22@gmail.com`…

そして、`app.yml` を変更した後にアプリを再構築したのは当然です。

この問題が発生する理由と、その解決方法について何かアイデアはありますか？

---

<div class="post-metadata">

### Author: ![Simon\_Manning](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon_manning/32/198596_2.png) [@Simon\_Manning](https://meta.discourse.org/u/Simon_Manning)
#### Post date: [2022 年 7 月 24 日午後 12:10 UTC](https://meta.discourse.org/t/sending-emails-with-smtp-credentials-using-amazon-ses-works-but-not-from-discourse/233795/2 "2022-07-24T12:10:25Z")

</div>

エラーメッセージは、`monocycle.info@gmail.com` のIDを作成して確認する必要があることを示唆しています。ラベル（`+verp-...`）は、ラベルなしでアドレスが確認されるとすべて受け入れられるため、確認する必要はありません。

これは、返信時のメールアドレスがReturn-Pathアドレスとして使用されるためであり、これは引用で確認が必要と強調されているタイプの一つです。

他の方法で送信できる理由がわかりませんが、AmazonダッシュボードとSMTPテストツールのテストは、Discourseが行うようにReply-To/Return-Pathアドレスとして使用するのではなく、返信時のメールアドレスに送信していたため、機能したのだと思います。

IDに関するドキュメントはこちらです。

> **[Creating and verifying identities in Amazon SES - Amazon Simple Email Service](https://docs.aws.amazon.com/ses/latest/dg/creating-identities.html)**
>
> Create an identity at the domain level or can create email address identities.

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [2022 年 7 月 24 日午後 12:14 UTC](https://meta.discourse.org/t/sending-emails-with-smtp-credentials-using-amazon-ses-works-but-not-from-discourse/233795/3 "2022-07-24T12:14:56Z")

</div>

はい、こちらに記載されている通りです。

> [@Troubleshooting Amazon AWS SES sending email via SMTP](https://meta.discourse.org/t/troubleshooting-amazon-aws-ses-sending-email-via-smtp/163100/11?u=canapin):
>
> I was wondering if it might be something like that. My current SendGrid setup has been working for years and has the following: Are you saying that what I’m trying to do simply isn’t possible in SES because of the reply-to address being on the [gmail.com](http://gmail.com) domain?

最初は理解できませんでしたが、SESでGmailアドレスを認証済みアドレスとして追加してみます。

---

<div class="post-metadata">

### Author: ![Jagster](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jagster/32/192154_2.png) [@Jagster](https://meta.discourse.org/u/Jagster)
#### Post date: [2022 年 7 月 24 日午後 12:30 UTC](https://meta.discourse.org/t/sending-emails-with-smtp-credentials-using-amazon-ses-works-but-not-from-discourse/233795/4 "2022-07-24T12:30:44Z")

</div>

AFAIK、SESで±アドレスを使用することはできません。しかし、Discourse経由で毎日SESを使用しています。

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [2022 年 7 月 24 日午後 12:52 UTC](https://meta.discourse.org/t/sending-emails-with-smtp-credentials-using-amazon-ses-works-but-not-from-discourse/233795/5 "2022-07-24T12:52:28Z")

</div>

`monocycle.info@gmail.com` を確認し、Discourse がユーザーにメールを送信できることを確認しました。メールでの返信機能も動作します。  
何か問題があれば、数日中に確認します。

> [@Jagster](#):
>
> 私の知る限り、SES では ± アドレスを使用できません。

もう少し詳しく説明していただけますか？私が書いたこと（すべて正常に動作しているように見えること）に関してです。🙂

---

<div class="post-metadata">

### Author: ![Jagster](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jagster/32/192154_2.png) [@Jagster](https://meta.discourse.org/u/Jagster)
#### Post date: [2022 年 7 月 24 日午後 1:23 UTC](https://meta.discourse.org/t/sending-emails-with-smtp-credentials-using-amazon-ses-works-but-not-from-discourse/233795/6 "2022-07-24T13:23:54Z")

</div>

2つの異なる点があります。

- SESは、着信または発信トラフィックでプラス記号(+)で区切られたアドレスを使用できません（プラス記号の形式の正確な用語を本当に覚えていません）。
- DiscourseからSES経由で常にメールを送信しています。

メールによる作成/返信を使用しようとしたとき、そのためにGmailを使用する必要がありました。

これはあなたに関連がありますか…全くわかりません 🤦‍♂️

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [2022 年 7 月 24 日午後 1:28 UTC](https://meta.discourse.org/t/sending-emails-with-smtp-credentials-using-amazon-ses-works-but-not-from-discourse/233795/7 "2022-07-24T13:28:05Z")

</div>

なるほど、明確化ありがとうございます。SESでは±アドレスを使用していないので、私のケースでは関連がないと思います。🙂

---

<div class="post-metadata">

### Author: ![Simon\_Manning](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon_manning/32/198596_2.png) [@Simon\_Manning](https://meta.discourse.org/u/Simon_Manning)
#### Post date: [2022 年 7 月 24 日午後 1:46 UTC](https://meta.discourse.org/t/sending-emails-with-smtp-credentials-using-amazon-ses-works-but-not-from-discourse/233795/8 "2022-07-24T13:46:58Z")

</div>

> [@Jagster](#):
>
> - SESは、着信または発信トラフィックで+アドレスを使用できません（+形式の正しい用語は本当に思い出せません）

Amazonではラベルと呼んでいますが、`user+label@domain`アドレスのことを指しているのであれば、それがメール用語なのか、単にAmazonの用語なのかは覚えていません。これらがサポートされていないと確信していますか？ユーザーはかなり一般的に使用しています。

ドキュメントで見つけられる唯一のことは、SMTPUTF8拡張がサポートされておらず、ローカルパート（@より前）が[7ビットASCII文字](https://en.wikipedia.org/wiki/Email_address#Local-part)に制限されていることです。これには+文字が含まれます。

---

<div class="post-metadata">

### Author: ![Jagster](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jagster/32/192154_2.png) [@Jagster](https://meta.discourse.org/u/Jagster)
#### Post date: [2022 年 7 月 24 日午後 1:47 UTC](https://meta.discourse.org/t/sending-emails-with-smtp-credentials-using-amazon-ses-works-but-not-from-discourse/233795/9 "2022-07-24T13:47:21Z")

</div>

いいえ、そうではありませんが、`+verp…` はそのように機能します。それとも、私が完全に間違っていますか？

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [2022 年 7 月 24 日午後 1:54 UTC](https://meta.discourse.org/t/sending-emails-with-smtp-credentials-using-amazon-ses-works-but-not-from-discourse/233795/10 "2022-07-24T13:54:44Z")

</div>

まあ、メール関連のことはあまり理解していないので、私の返信は少し的外れになることがあります。

* * *

私のメールでの返信設定は、確かに「+」などを使用するGmailアドレスです。

「メールでの返信」設定がオフの場合、Discourseのメール送信は機能します（私の記憶が正しければ）。

「メールでの返信」設定がオンで、SESでGmailアドレスを認証しない場合、Gmailの返信先アドレスを持つかどうかにかかわらず、Discourseはメールを送信せず（例：テストメールやダイジェストメールにはGmailの返信先アドレスがありません）、`554 Message rejected: Email address is not verified` というエラーが発生します。

SESでGmailアドレスを認証すると、Gmailの返信先アドレスを持つかどうかにかかわらず、Discourseから送信されるすべてのメールが機能するようです。

もちろん、これらの仕組みについてもう少し詳しく知りたいのですが、機能している限りは…それが私の主な関心事です。😄

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [2022 年 8 月 26 日午前 12:08 UTC](https://meta.discourse.org/t/sending-emails-with-smtp-credentials-using-amazon-ses-works-but-not-from-discourse/233795/12 "2022-08-26T00:08:01Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
