Simon M.
Simon M.

Reputation: 2482

Send mail with ActionMailer

I'm asking almost the same question again but I still didn't find how I can resolve my problem. I want to send a mail to all my user when an article is published. I think I've set up ActionMailer successfully because I use MailCatcher to see if the mail goes and I catch the mail correctly but the mail do not arrive inbox.

Development.rb

config.action_mailer.raise_delivery_errors = true
config.action_mailer.perform_deliveries = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address:              'smtp.gmail.com',
port:                 587,
user_name:            '[email protected]',
password:             '********',
authentication:       'plain',
enable_starttls_auto: true  }

Source from MailCatcher

Date: Mon, 08 Jun 2015 07:39:44 -0700
From: [email protected]
To: contact@******.com
Message-ID: <[email protected]>
Subject: **TEST**
Mime-Version: 1.0
Content-Type: multipart/alternative;
 boundary="--==_mimepart_5575a930a3eb8_f723f9271aa20c4319c";
 charset=UTF-8
Content-Transfer-Encoding: 7bit


----==_mimepart_5575a930a3eb8_f723f9271aa20c4319c
Content-Type: text/plain;
 charset=UTF-8
Content-Transfer-Encoding: 7bit

*******************************
===============================================

----==_mimepart_5575a930a3eb8_f723f9271aa20c4319c
Content-Type: text/html;
 charset=UTF-8
Content-Transfer-Encoding: 7bit

<html>
  <body>
    <!DOCTYPE html>
<html>
  <head>
    <meta content='text/html; charset=UTF-8' http-equiv='Content-Type' />
  </head>
  <body>
    <h1>oooooooooooooooooooooo</h1>
  </body>
</html>

  </body>
</html>

----==_mimepart_5575a930a3eb8_f723f9271aa20c4319c--

I really don't know how to resolve this, I got no error but it doesn't work. How can I do to make it work ?

Upvotes: 0

Views: 51

Answers (1)

Prashant4224
Prashant4224

Reputation: 1601

You missing the default_url_options, Here the Reference

config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }

config.action_mailer.raise_delivery_errors = true
config.action_mailer.perform_deliveries = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
  address:              'smtp.gmail.com',
  port:                 587,
  user_name:            '[email protected]',
  password:             '********',
  authentication:       'plain',
  enable_starttls_auto: true  
}

Upvotes: 1

Related Questions