# emails:test rake 작업은 이메일이 비활성화되어 있으면 성공적인 전달을 보고하지 않아야 합니다

**URL:** https://meta.discourse.org/t/the-emails-test-rake-task-should-not-report-successful-delivery-when-email-is-disabled/185109
**Category:** Bug
**Created:** [4월 1, 2021, 2:12오후 UTC](https://meta.discourse.org/t/the-emails-test-rake-task-should-not-report-successful-delivery-when-email-is-disabled/185109 "2021-04-01T14:12:32Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![supermathie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/supermathie/32/507518_2.png) [@supermathie](https://meta.discourse.org/u/supermathie)
#### Post date: [4월 1, 2021, 2:12오후 UTC](https://meta.discourse.org/t/the-emails-test-rake-task-should-not-report-successful-delivery-when-email-is-disabled/185109/1 "2021-04-01T14:12:32Z")

</div>

[Email test area should warn if emails are disabled](https://meta.discourse.org/t/email-test-area-should-warn-if-emails-are-disabled/95269?u=supermathie) 의 내용과 유사합니다:

다음은 오해의 소지가 있습니다:

```plaintext
$ rake 'emails:test[michael@example.com]'
Testing sending to michael@example.com using mx-out:25.
SMTP server connection successful.
Sending to michael@example.com. . . 
Mail accepted by SMTP server.

If you do not receive the message, check your SPAM folder
or test again using a service like http://www.mail-tester.com/.

If the message is not delivered it is not a problem with Discourse.

Check the SMTP server logs to see why it failed to deliver the message.

```

이 경우 `SiteSetting.disable_emails == "non-staff"`였기 때문에 이메일이 전송되지 않았습니다.

이 rake 작업에서 이에 대한 경고를 표시해야 합니다. 다음 중 어떤 방식을 취할까요?

- `Email::Sender#send`에 메시지가 전송되었는지를 나타내는 값을 반환하는 로직을 추가합니다 (예: sent, skipped, disabled, no\_message)
- 또는 `emails:test` 작업에 `disable_emails`만 테스트하는 로직을 추가합니다

---

<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: [4월 1, 2021, 2:21오후 UTC](https://meta.discourse.org/t/the-emails-test-rake-task-should-not-report-successful-delivery-when-email-is-disabled/185109/2 "2021-04-01T14:21:13Z")

</div>

그 코드 중 일부에는 내가 관여한 부분이 있는 것 같아…

그러면 메일이 수락되었다는 부분은 거짓말이라는 거야?

가장 원했던 것은 rake 태스크가 이메일 비활성화 설정을 무시하도록 하는 거야. 콘솔에 접근할 수 있는 사람이라면 테스트 이메일을 보낼 수 있어야 하니까.

---

<div class="post-metadata">

### Author: ![supermathie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/supermathie/32/507518_2.png) [@supermathie](https://meta.discourse.org/u/supermathie)
#### Post date: [4월 1, 2021, 2:50오후 UTC](https://meta.discourse.org/t/the-emails-test-rake-task-should-not-report-successful-delivery-when-email-is-disabled/185109/3 "2021-04-01T14:50:10Z")

</div>

> [@pfaffman](#):
>
> 가장 원했던 것은 rake 작업이 이메일 비활성화 설정을 무시하는 것이었습니다.

동의합니다. 좋은 지적입니다. 만약의 상황에 대비하여 이메일을 보내면서도 이메일이 비활성화되어 있음을 보고하는 것이 좋은 아이디어일 수 있습니다.

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [7월 8, 2021, 11:27오후 UTC](https://meta.discourse.org/t/the-emails-test-rake-task-should-not-report-successful-delivery-when-email-is-disabled/185109/6 "2021-07-08T23:27:09Z")

</div>

`SiteSetting.disable_emails`로 인해 메시지가 전송되지 않는 문제를 재현하지는 못했지만, `EmailLog`가 반환된 경우에만 성공으로 보고하도록 스크립트를 수정했고, `disable_emails` 설정에 대한 추가 경고도 추가했습니다.

```plaintext
$ bin/rake 'emails:test[]'
Testing sending to using localhost:1025, username: with auth.
SMTP server connection successful.
Sending to . . . 
Mail was not sent.

Reason: message.to is blank

### WARNING
The `disable_emails` site setting is currently set to non-staff.
Consider changing it to 'no' before performing any further troubleshooting.

```

그리고

```plaintext
Sending to michael@example.com. . . 
Mail accepted by SMTP server.
Message-ID: dfaf1c88-aab6-474b-b50c-8c500afb6291@localhost

If you do not receive the message, check your SPAM folder
[...]

```

[https://github.com/discourse/discourse/pull/13674](https://github.com/discourse/discourse/pull/13674)

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [7월 9, 2021, 10:00오후 UTC](https://meta.discourse.org/t/the-emails-test-rake-task-should-not-report-successful-delivery-when-email-is-disabled/185109/7 "2021-07-09T22:00:39Z")

</div>

이 주제는 21시간 후 자동으로 닫혔습니다. 더 이상 새로운 답글을 작성할 수 없습니다.
