# Discourse中Gmail发送邮件的配置方法

**URL:** <https://www.shiwantech.xyz/t/topic/144>\
**Category:** Discourse\
**Created:** [2024 年10 月 3 日 02:51 UTC](https://www.shiwantech.xyz/t/topic/144 "2024-10-03T02:51:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

作者： ![itpanpan163](https://www.shiwantech.xyz/letter_avatar_proxy/v4/letter/i/ccd318/32.png) [@itpanpan163](https://www.shiwantech.xyz/u/itpanpan163)\
发布日期： [2024 年10 月 3 日 02:51 UTC](https://www.shiwantech.xyz/t/topic/144/1 "2024-10-03T02:51:28Z")

</div>

一、Google账户的设置  
1.确定账号未被限制，在浏览器上能正常登陆gmail.  
2.在设置-\>转发和 POP/IMAP 中开启pop和imap

 ![11](https://www.shiwantech.xyz/uploads/default/original/1X/d5a90384e77b77341a229aef1ba9f9ff5e8aa50a.png)  
 ![222](https://www.shiwantech.xyz/uploads/default/original/1X/3b34a49bb0c293673e25472fddd0175959fa70da.png)  
3.开启账号的 二步验证 和设置 应用专用密码  
 ![33](https://www.shiwantech.xyz/uploads/default/original/1X/46dc5ad0ab906e879c615246f7c0e96a0ef951fa.png)  
 ![44](https://www.shiwantech.xyz/uploads/default/original/1X/93191909309f5423a2966304393b29f5e13470d9.png)

4.使用如下链接生成16位应用专用密码:  
`https://security.google.com/settings/security/apppasswords`  
`https://myaccount.google.com/apppasswords`

在这里根据提示生成一个应用专用密码。  
（复制4组16位密码的时候，注意将密码组之间的空格去掉）

小提示：  
应用专用密码是一个 16 位数的密码，可授权安全性较低的应用或设备访问您的 Google 账号。应用专用密码只能与已开启两步验证的账号搭配使用。  
为了帮助保护您的账号，我们会在您更改 Google 账号密码后撤消您的应用专用密码。如需继续通过 Google 账号使用应用，请创建新的应用专用密码。

另外，如果想取消专用应用密码，启用安全较低的密码可以用下面的链接  
`https://myaccount.google.com/lesssecureapps`

二、Discourse中SMTP的设置

```auto
  # WARNING the char '#' in SMTP password can cause problems!
  DISCOURSE_SMTP_ADDRESS: smtp.gmail.com
  DISCOURSE_SMTP_PORT: 587
  DISCOURSE_SMTP_USER_NAME: gmail的用户名，也有说填写gmail电子邮件地址的
  DISCOURSE_SMTP_PASSWORD: 此处填写gmail的16位的应用专用密码
  #DISCOURSE_SMTP_ENABLE_START_TLS: true # (optional, default true)
  DISCOURSE_SMTP_DOMAIN: gmail.com # (required by some providers)
  DISCOURSE_NOTIFICATION_EMAIL: gmail电子邮件地址

  ## If you added the Lets Encrypt template, uncomment below to get a free SSL certificate
  LETSENCRYPT_ACCOUNT_EMAIL: SSL接收证书的邮件地址

```
