# Email test from the console?

**URL:** https://meta.discourse.org/t/email-test-from-the-console/87295
**Category:** Development
**Created:** [11 mei 2018 om 22:03 UTC](https://meta.discourse.org/t/email-test-from-the-console/87295 "2018-05-11T22:03:23Z")
**Posts on this page:** 4
**Page:** 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: [11 mei 2018 om 22:03 UTC](https://meta.discourse.org/t/email-test-from-the-console/87295/1 "2018-05-11T22:03:23Z")

</div>

Is there a way to initiate an email test from the Rails console? For a zillion reasons I would love to be able to send a test email without having to create an account. I’ve looked in `config/routes.rb` and grepped all over the models, controllers, and lib.

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [11 mei 2018 om 22:32 UTC](https://meta.discourse.org/t/email-test-from-the-console/87295/2 "2018-05-11T22:32:06Z")

</div>

I haven’t tried it, but AFAIK it can be done with  
[https://github.com/sj26/mailcatcher](https://github.com/sj26/mailcatcher)

Maybe development only and not production?

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [11 mei 2018 om 22:37 UTC](https://meta.discourse.org/t/email-test-from-the-console/87295/3 "2018-05-11T22:37:45Z")

</div>

> [@pfaffman](#):
>
> Is there a way to initiate an email test from the Rails console?

If sidekiq is running, you can do exactly what the [Admin Email Controller](https://github.com/discourse/discourse/blob/abda21a41f6de4508e6c33afd9325de131b21967/app/controllers/admin/email_controller.rb#L13) does

```ruby
Jobs::TestEmail.new.execute(to_address: "foo@bar.com")

```

If sidekiq isn’t running, then you need to go deeper and do what the [Test Email Job](https://github.com/discourse/discourse/blob/abda21a41f6de4508e6c33afd9325de131b21967/app/jobs/regular/test_email.rb#L14-L15) does

```ruby
Email::Sender.new(TestMailer.send_test("foo@bar.com"), :test_message).send 

```

---

<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: [12 mei 2018 om 00:55 UTC](https://meta.discourse.org/t/email-test-from-the-console/87295/4 "2018-05-12T00:55:41Z")

</div>

Thanks, @zogstrip! I guess my `grep`s of the controllers were too specific.

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