2017-01-04 12 views
0

私たちは実働アプリケーションでSendGridを使用していますが、正常に動作します。私たちは最近、開発中に新機能/電子メールをテストしようとしていましたが、電子メールを送信するようには思えませんでした。どこが間違っているのか?我々は同様の機能をプロダクションに使用しており、SendGridの実装ガイドにも従っています。シンプルなものが欠けているような気がする!Rails SendGrid Email開発環境から

まず私はSENDGRID_USERNAMESENDGRID_PASSWORDをエクスポートし、キックのためには、私はこれらが存在し、コンソールで確認し、正しいきた私の.bash_profile

export SENDGRID_USERNAME=xxxxxxx 
export SENDGRID_PASSWORD=xxxxxxx 

にこれを追加しました。

<p>Hi! Sendgrid test</p> 

そしてDeveloperMailerファイル:私はコンソールに電子メールを送信するために行くとき

config.action_mailer.raise_delivery_errors = true 
    config.action_mailer.default_url_options = { :host => 'localhost:3000' } 
    config.action_mailer.perform_deliveries = true 
    config.action_mailer.delivery_method = :smtp 

    config.action_mailer.smtp_settings = { 
    address:    'smtp.sendgrid.net', 
    port:     '587', 
    domain:    'localhost:3000', 
    user_name:   ENV['SENDGRID_USERNAME'], 
    password:    ENV['SENDGRID_PASSWORD'], 
    authentication:  :plain, 
    enable_starttls_auto: true } 

class DeveloperMailer < ActionMailer::Base 
    default from: "[email protected]" 

    def developer_email(developer_id) 
    @recipients = ["[email protected]"] 
    mail(to: @recipients, subject: 'Does sendgrid work?') 
    end 
end 

development.rbファイルを更新developer_email.html.erbファイルを作成した

それは送信されたように動作しますが、電子メールは決して実際に到着しません:

DeveloperMailer.developer_email(1)#メールを送信します。仕事をしているようです:

2.3.1 :001 > DeveloperMailer.developer_email(1) 
    Rendered developer_mailer/developer_email.html.erb (1.5ms) 

DeveloperMailer#developer_email: processed outbound mail in 133.3ms 
=> #<Mail::Message:70263824429080, Multipart: false, Headers: <From: [email protected]>, <To: ["[email protected]"]>, <Subject: Does SendGrid Work?>, <Mime-Version: 1.0>, <Content-Type: text/html>> 

#But I never get anything sent to my email 

何が不足していると思いますか?しかし

config.action_mailer.raise_delivery_errors = true 
    config.action_mailer.default_url_options = { :host => 'localhost:3000' } 
    config.action_mailer.perform_deliveries = true 
    config.action_mailer.delivery_method = :smtp 

    config.action_mailer.smtp_settings = { 
    address:    'smtp.sendgrid.net', 
    domain:    'theoremreach.com', 
    user_name:   ENV['SENDGRID_USERNAME'], 
    password:    ENV['SENDGRID_PASSWORD'], 
    authentication:  :plain, 
    enable_starttls_auto: true } 

まだ電子メール:

EDITはdevelopment.rbファイルを更新しました。

答えて

0

domainは、実際の環境のドメインではなく、SMTP HELOドメインです。それをSendGridプロファイルで使用しているのと同じドメインに変更し、ポートを指定せずに試してみてください。

+0

私は更新されたコードを投稿しました。しかし、メールはありません:( –

+0

あなたのSendGridアクティビティはhttps://app.sendgrid.com/email_activityで見ていますか? – bwest

+0

何もありません。 –