# Help to send email required

**URL:** <https://discuss.rubyonrails.org/t/help-to-send-email-required/66664>\
**Category:** rubyonrails-talk\
**Created:** [March 24, 2013, 9:11am UTC](https://discuss.rubyonrails.org/t/help-to-send-email-required/66664 "2013-03-24T09:11:15Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tommy\_Pollak](https://avatars.discourse-cdn.com/v4/letter/t/53a042/32.png) [@Tommy\_Pollak](https://discuss.rubyonrails.org/u/Tommy_Pollak)\
**Post date:** [March 24, 2013, 9:11am UTC](https://discuss.rubyonrails.org/t/help-to-send-email-required/66664/1 "2013-03-24T09:11:15Z")

</div>

From a Rails application containing email addresses I want to send emails. Therefore I am testing sending emails.

It does not work though I have read a lot about how to do it. I guess my …/config/initializers/mail.rb is wrong.

I have based the settings on the answers here but I do not understand them fully.

File content:

ActionMailer::Base.smtp\_settings = { address: “smtp.x.y”, port: 465, domain: “x.y” user\_name: “me”, password: “my”, authentication: :login, enable\_starttls\_auto: true }

This is based on my settings in Thunderbird for outgoing server:

Server Name smtp.x.y Port 465 User name me Authentication method Normal password Connection Security SSL/TLS

The error is reported as

Completed 500 Internal Server Error in 60254ms

Timeout::Error (Timeout::Error): app/controllers/mail\_messages\_controller.rb:56:in `block in create' app/controllers/mail_messages_controller.rb:54:in `create’

OS Ubuntu 12.04 Ruby 1.9.3 Rails 3.2.9

---

<div class="post-metadata">

**Author:** ![jleake](https://avatars.discourse-cdn.com/v4/letter/j/cc9497/32.png) [@jleake](https://discuss.rubyonrails.org/u/jleake)\
**Post date:** [March 24, 2013, 12:43pm UTC](https://discuss.rubyonrails.org/t/help-to-send-email-required/66664/2 "2013-03-24T12:43:41Z")

</div>

mailers/user\_mailer.rb class UserMailer \< ActionMailer::Base default from: “youremailaddress”

```
  # Subject can be set in your I18n file at config/locales/en.yml
  # with the following lookup:

```

---

<div class="post-metadata">

**Author:** ![Tommy\_Pollak](https://avatars.discourse-cdn.com/v4/letter/t/53a042/32.png) [@Tommy\_Pollak](https://discuss.rubyonrails.org/u/Tommy_Pollak)\
**Post date:** [March 24, 2013, 2:34pm UTC](https://discuss.rubyonrails.org/t/help-to-send-email-required/66664/3 "2013-03-24T14:34:52Z")

</div>

Hmmm, You really repeat one of the points that make confused - :domain =\> “yourwebsite”,

I am running on my client, localhost, and do not have any own web address, so what should domain be set to?

---

<div class="post-metadata">

**Author:** ![jleake](https://avatars.discourse-cdn.com/v4/letter/j/cc9497/32.png) [@jleake](https://discuss.rubyonrails.org/u/jleake)\
**Post date:** [March 24, 2013, 2:50pm UTC](https://discuss.rubyonrails.org/t/help-to-send-email-required/66664/4 "2013-03-24T14:50:15Z")

</div>

Hi, Sorry I do not know. This also confused me. Try using a name associated with your email service provider. It should not have anything to do with where your app server is running from.

John

---

<div class="post-metadata">

**Author:** ![Tommy\_Pollak](https://avatars.discourse-cdn.com/v4/letter/t/53a042/32.png) [@Tommy\_Pollak](https://discuss.rubyonrails.org/u/Tommy_Pollak)\
**Post date:** [March 24, 2013, 3:49pm UTC](https://discuss.rubyonrails.org/t/help-to-send-email-required/66664/5 "2013-03-24T15:49:26Z")

</div>

I tried to set up a different mail account I have. The response was different “Connection refused - connect(2)”. This is OK, I believe, because my ISP does not allow mail relay.

So obviously I get in touch with my ISP but am unable to login. Any hints?

---

<div class="post-metadata">

**Author:** ![Tommy\_Pollak](https://avatars.discourse-cdn.com/v4/letter/t/53a042/32.png) [@Tommy\_Pollak](https://discuss.rubyonrails.org/u/Tommy_Pollak)\
**Post date:** [March 24, 2013, 8:58pm UTC](https://discuss.rubyonrails.org/t/help-to-send-email-required/66664/6 "2013-03-24T20:58:15Z")

</div>

Problem solved!

Careful inspection of the Thunderbird outgoing server settings revealed that my mailer smtp.x.y required the following settings in …/config/initializers/mail.rb:

ActionMailer::Base.smtp\_settings = { … :enable\_starttls\_auto =\> false, :ssl =\> true }

Once this was corrected I got the report that the from field in the mail had to contain an existing domain.

domain in the smtp\_settings is set to x.y where x.y is taken from address =\> smtp.x.y but I do not know if this of any importance.

Thanks for all hints.
