Note that there are some explanatory texts on larger screens.

plurals
  1. POSendgrid/can't get emails
    primarykey
    data
    text
    <p>Now I am trying to set up a contact form and removed all the errors.But I can't get email.Could you give me some advice?</p> <p>☆heroku logs</p> <pre><code> 2013-12-18T06:20:34.807594+00:00 app[web.1]: Started POST "/contacts" for 118.237.94.47 at 2013-12-18 06:20:34 +0000 2013-12-18T06:20:34.813037+00:00 app[web.1]: Processing by ContactsController#create as HTML 2013-12-18T06:20:34.813037+00:00 app[web.1]: Parameters: {"utf8"=&gt;"✓", "authenticity_token"=&gt;"2e9zz3cX0tZwYTZhaPbRRYQufff31fZk4OjjF7sdeo=", "contact"=&gt;{"name"=&gt;"じゃじゃじゃ", "email"=&gt;"jaja@gmail.com", "content"=&gt;"じゃじゃじゃ"}, "commit"=&gt;"Create Contact"} 2013-12-18T06:20:34.843217+00:00 app[web.1]: Rendered contact_mailer/sent.text.erb (0.5ms) 2013-12-18T06:20:35.265031+00:00 heroku[router]: at=info method=POST path=/contacts host=www.tsundoku-buster.jp fwd="118.237.94.47" dyno=web.1 connect=4ms service=464ms status=302 bytes=116 2013-12-18T06:20:35.259745+00:00 app[web.1]: 2013-12-18T06:20:35.259745+00:00 app[web.1]: Sent mail to myemail@gmail.com (412ms) 2013-12-18T06:20:35.260551+00:00 app[web.1]: Redirected to http://www.tsundoku-buster.jp/static_pages/contact 2013-12-18T06:20:35.260715+00:00 app[web.1]: Completed 302 Found in 448ms (ActiveRecord: 11.4ms) </code></pre> <p>What I have done so far is as follows.</p> <p>①app/mailers/contact_mailer.rb</p> <pre><code>class ContactMailer &lt; ActionMailer::Base default from: "myemail@gmail.com" # Subject can be set in your I18n file at config/locales/en.yml # with the following lookup: # # en.contact_mailer.sent.subject # def sent(contact) @contact = contact mail(:to =&gt; "myemail@gmail.com", :subject =&gt; 'TsundokuBuster発お問い合わせ') end end </code></pre> <p>②app/views/contact_mailer/sent.text.erb</p> <pre><code>以下の内容でお問い合わせ頂きました。 お名前 &lt;%= @contact.name %&gt; メールアドレス &lt;%= @contact.email %&gt; お問い合わせ内容 &lt;%= @contact.content %&gt; </code></pre> <p>③contact.rb</p> <pre><code>class Contact &lt; ActiveRecord::Base attr_accessible :name, :email, :content validates :name, :email, :content , :presence =&gt; true end </code></pre> <p>cf.<a href="http://sendgrid.com/docs/Integrate/Frameworks/rubyonrails.html" rel="nofollow">http://sendgrid.com/docs/Integrate/Frameworks/rubyonrails.html</a></p> <p>④contacts_controller.rb</p> <pre><code> #encoding: utf-8 class ContactsController &lt; ApplicationController def create @contact = Contact.new(params[:contact]) if @contact.save ContactMailer.sent(@contact).deliver redirect_to static_pages_contact_path, :notice =&gt; 'お問い合わせありがとうございました。' else render static_pages_contact_path, :alert =&gt; 'お問い合わせに不備があります。' end end end </code></pre> <p>⑤Adding Sendgrid add-on at heroku dashboard</p> <p>⑥Search for my SENDGRID_USERNAME and SENDGRID_PASSWORD</p> <p>cf.<a href="https://devcenter.heroku.com/articles/sendgrid" rel="nofollow">https://devcenter.heroku.com/articles/sendgrid</a></p> <p>⑦Editing config/environment.rb</p> <pre><code>ActionMailer::Base.smtp_settings = { :address =&gt; 'smtp.sendgrid.net', :port =&gt; '587', :authentication =&gt; :plain, :user_name =&gt; ENV['myappusername@heroku.com'], :password =&gt; ENV['mypassword'], :domain =&gt; 'www.mydomain.jp', :enable_starttls_auto =&gt; true } ActionMailer::Base.delivery_method = :smtp </code></pre> <p>⑧git add. git commit git push heroku master</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload