# 新規セットアップ：Gmail 経由でのメール送信時にエラーが発生

**URL:** https://meta.discourse.org/t/new-setup-errors-when-trying-to-send-emails-through-gmail/133670
**Category:** Self-hosting
**Created:** [2019 年 11 月 18 日午前 9:55 UTC](https://meta.discourse.org/t/new-setup-errors-when-trying-to-send-emails-through-gmail/133670 "2019-11-18T09:55:26Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![yacineSmartly](https://avatars.discourse-cdn.com/v4/letter/y/54ee81/32.png) [@yacineSmartly](https://meta.discourse.org/u/yacineSmartly)
#### Post date: [2019 年 11 月 18 日午前 9:55 UTC](https://meta.discourse.org/t/new-setup-errors-when-trying-to-send-emails-through-gmail/133670/1 "2019-11-18T09:55:26Z")

</div>

こんにちは、

プライベートクラウド上の Ubuntu Server 16.04 に Discourse をセットアップしました。インストールはすべて正常に完了しました。

現在、メール設定のテストで問題が発生しています。正しい情報を入力したのですが、メールが届きません。同じ設定を別の Node.js アプリケーションで使用した際は問題なく動作しました。

どこが間違っているのでしょうか？

私の設定は以下の通りです：

```
DISCOURSE_HOSTNAME: forum.smartly.ai
DISCOURSE_DEVELOPER_EMAILS: 'smartly.retailbanking@gmail.com'
DISCOURSE_SMTP_ADDRESS: smtp.gmail.com
DISCOURSE_SMTP_PORT: 465
DISCOURSE_SMTP_USER_NAME: smartly.retailbanking@gmail.com
DISCOURSE_SMTP_PASSWORD: "xxxxx"
DISCOURSE_SMTP_ENABLE_START_TLS: false 

```

非常に困っています。ご返信をいただければ幸いです。

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [2019 年 11 月 18 日午前 11:23 UTC](https://meta.discourse.org/t/new-setup-errors-when-trying-to-send-emails-through-gmail/133670/2 "2019-11-18T11:23:52Z")

</div>

Gmail を SMTP サーバーとして使用することは、Gmail の利用規約に違反し、サポート対象外です。

---

<div class="post-metadata">

### Author: ![yacineSmartly](https://avatars.discourse-cdn.com/v4/letter/y/54ee81/32.png) [@yacineSmartly](https://meta.discourse.org/u/yacineSmartly)
#### Post date: [2019 年 11 月 18 日午前 11:40 UTC](https://meta.discourse.org/t/new-setup-errors-when-trying-to-send-emails-through-gmail/133670/3 "2019-11-18T11:40:37Z")

</div>

Node.js アプリでも同じ設定を使用しました。アカウントのセキュリティでこの種類のアプリケーションを許可し、問題なく動作しています。  
Gmail の設定で「安全性の低いアプリ」を有効にしても、Discourse は Gmail アプリとしてサポートされていないのでしょうか？もしそうであれば、どの設定を使用すべきでしょうか？

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [2019 年 11 月 18 日午前 11:45 UTC](https://meta.discourse.org/t/new-setup-errors-when-trying-to-send-emails-through-gmail/133670/4 "2019-11-18T11:45:38Z")

</div>

他のアプリで動作した理由については不明ですが、Gmail の利用規約に違反していることに変わりはありません。推奨されるメールサービスのリストについては、[discourse/docs/INSTALL-email.md at main · discourse/discourse · GitHub](https://github.com/discourse/discourse/blob/master/docs/INSTALL-email.md) をご覧ください。

---

<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: [2019 年 11 月 18 日午後 1:00 UTC](https://meta.discourse.org/t/new-setup-errors-when-trying-to-send-emails-through-gmail/133670/5 "2019-11-18T13:00:20Z")

</div>

> [@pfaffman](#):
>
> Gmail を SMTP サーバーとして使用することは、Gmail の利用規約に違反します

その点について確信がありますか？私は以下の制限を見つけました：

> **[Gmail sending limits in Google Workspace  |  Google Workspace Help](https://knowledge.workspace.google.com/admin/gmail/gmail-sending-limits-in-google-workspace?hl=en&visit_id=639129377728365712-1169346963&rd=1)**

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [2019 年 11 月 18 日午後 1:58 UTC](https://meta.discourse.org/t/new-setup-errors-when-trying-to-send-emails-through-gmail/133670/6 "2019-11-18T13:58:00Z")

</div>

G Suite と Gmail は同じものではありません。上記の例を見ると、Gmail をお使いのようです。

メールサービスを利用する方が簡単です。メールを動作させる問題に対する簡単な解決策を望まない場合、私のアドバイスは役に立たないかもしれません。

もし

---

<div class="post-metadata">

### Author: ![Stephen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stephen/32/95011_2.png) [@Stephen](https://meta.discourse.org/u/Stephen)
#### Post date: [2019 年 11 月 18 日午後 2:52 UTC](https://meta.discourse.org/t/new-setup-errors-when-trying-to-send-emails-through-gmail/133670/7 "2019-11-18T14:52:20Z")

</div>

@Canapin 上記のユーザー名は @gmail.com です。G Suite のドキュメントは適用されません。G Suite は有料サービスであるため、はい、これは利用規約に違反しています。

Google が定めた非常に合理的なルールを破るお手伝いはできません。特に、無料でサポートされている代替手段が存在する場合はなおさらです。

---

<div class="post-metadata">

### Author: ![yacineSmartly](https://avatars.discourse-cdn.com/v4/letter/y/54ee81/32.png) [@yacineSmartly](https://meta.discourse.org/u/yacineSmartly)
#### Post date: [2019 年 11 月 19 日午後 4:57 UTC](https://meta.discourse.org/t/new-setup-errors-when-trying-to-send-emails-through-gmail/133670/8 "2019-11-19T16:57:36Z")

</div>

ご返信ありがとうございます。Gsuite で試してみましたが、これも動作しません。Gsuite で追加したメールアドレスを使用し、外部アプリからの SMTP 利用を許可しましたが、結果は同じです。SendGrid や Discourse が対応している他のサービスを試してみようと思います。

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [2019 年 11 月 19 日午後 5:07 UTC](https://meta.discourse.org/t/new-setup-errors-when-trying-to-send-emails-through-gmail/133670/9 "2019-11-19T17:07:24Z")

</div>

GSuite をメール送信に使用することはお勧めしませんが、最近あるクライアントが[この手順](https://crunchify.com/how-to-setup-email-for-discourse-forum-with-google-apps-smtp-relay-right-way/)に従い、GSuite でメールを送信しています。

---

<div class="post-metadata">

### Author: ![yacineSmartly](https://avatars.discourse-cdn.com/v4/letter/y/54ee81/32.png) [@yacineSmartly](https://meta.discourse.org/u/yacineSmartly)
#### Post date: [2019 年 11 月 21 日午後 4:49 UTC](https://meta.discourse.org/t/new-setup-errors-when-trying-to-send-emails-through-gmail/133670/10 "2019-11-21T16:49:18Z")

</div>

[このリンク](https://crunchify.com/how-to-setup-email-for-discourse-forum-with-google-apps-smtp-relay-right-way/)に記載されている手順と同じ手順に従いましたが、同じ問題が発生したままです。そのため、Mailjet で新しいアカウントを作成しました。現在、./discourse-doctor を実行すると、メールが送信されたと表示されますが、メールボックスには何も届きません。また、自分のドメインからメールを送信できるように Mailjet 向けの新しい DNS 設定を追加しましたが、メールが送信されたと表示されても、実際にメールは届きません。

PS: スパムフォルダも空です。

---

<div class="post-metadata">

### Author: ![MarcP](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/marcp/32/160184_2.png) [@MarcP](https://meta.discourse.org/u/MarcP)
#### Post date: [2019 年 11 月 21 日午後 5:03 UTC](https://meta.discourse.org/t/new-setup-errors-when-trying-to-send-emails-through-gmail/133670/11 "2019-11-21T17:03:21Z")

</div>

私の意見では、Discourseを含むあらゆるウェブサイトにおいて、Gmail または Gsuite をトランザクションメールサービスとして使用するのは完全に不適切です。それらは本来その目的のために作られていません！

Mailgunを試してみてください（月間1万通まで **無料** です！）。または、代替案についてはこの[記事](https://github.com/discourse/discourse/blob/master/docs/INSTALL-email.md)をご覧ください。

---

<div class="post-metadata">

### Author: ![Stephen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stephen/32/95011_2.png) [@Stephen](https://meta.discourse.org/u/Stephen)
#### Post date: [2019 年 11 月 21 日午後 5:10 UTC](https://meta.discourse.org/t/new-setup-errors-when-trying-to-send-emails-through-gmail/133670/12 "2019-11-21T17:10:29Z")

</div>

それは正確ではありません。

GSuite はメールの送信を可能にしています（上記のドキュメントを参照）。ただし、制限を超えると、残りの GSuite アカウント全体が制限される可能性があります。

推奨されるメールプロバイダーを使用するのが望ましいですが、他のプロバイダーを選択する場合は、ご自身で動作するように設定してください。

---

<div class="post-metadata">

### Author: ![MarcP](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/marcp/32/160184_2.png) [@MarcP](https://meta.discourse.org/u/MarcP)
#### Post date: [2019 年 11 月 21 日午後 5:14 UTC](https://meta.discourse.org/t/new-setup-errors-when-trying-to-send-emails-through-gmail/133670/13 "2019-11-21T17:14:14Z")

</div>

> [@Stephen](#):
>
> それは正確ではありません。

正確ではないかもしれませんが、プロフェッショナルがトランザクションメールの送信にGmailやGsuiteを使用することを推奨することはありません。そのため、私の意見ではこれは避けるべきことです。もちろん、TSがそれを機能させたい場合は、彼次第です！

---

<div class="post-metadata">

### Author: ![Stephen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stephen/32/95011_2.png) [@Stephen](https://meta.discourse.org/u/Stephen)
#### Post date: [2019 年 11 月 21 日午後 5:15 UTC](https://meta.discourse.org/t/new-setup-errors-when-trying-to-send-emails-through-gmail/133670/14 "2019-11-21T17:15:15Z")

</div>

なら、意見を事実だと見せかけないでください。

TIL 私はプロじゃないんだね ¯\_(ツ)\_/¯

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [2019 年 11 月 21 日午後 9:07 UTC](https://meta.discourse.org/t/new-setup-errors-when-trying-to-send-emails-through-gmail/133670/15 "2019-11-21T21:07:22Z")

</div>

> [@yacineSmartly](#):
>
> さて、Mailjet で新しいアカウントを作成しました。今 ./discourse-doctor を実行すると、メールが送信されたと表示されます。しかし、メールボックスには何も届きません。

Mailjet のログを確認する必要があります。discourse-doctor が示している通り、これは Discourse 側の問題ではありません。

> [@MarcP](#):
>
> 私の意見では、Gmail または Gsuite を、Discourse を含むあらゆるウェブサイトのトランザショナルメールサービスとして使用するのはダメです。それは本来の用途ではないからです！

同意します。（ただし、ごく少量のホビースサイトなら例外かもしれません。それでも、Mailgun や同様のサービスを設定する方が簡単です。）

> [@Stephen](#):
>
> 推奨されるメールプロバイダーのいずれかを使用するのが望ましいです。それ以外を選ぶ場合は、それを動作させる責任はあなたにあります。

その通りです。
