2017-08-11 3 views
0

私は、メーラを動作させるためのサンプルアプリケーションを構築しました。アプリはhttps://blooming-brushlands-80122.herokuapp.com、 でホストされ、ソースコードはhereです。ここでは、アクションのメーラーに関連付けられている私の設定です:電子メールをレールで使用できない

config.action_mailer.delivery_method = :sendmail 
config.action_mailer.perform_deliveries = true 
config.action_mailer.raise_delivery_errors = true 
config.action_mailer.default_options = {from: '[email protected]'} 

とメーラー

def create 
     @user = User.new(user_params) 

     respond_to do |format| 
     if @user.save 

      # Sends email to user when user is created. 
      ExampleMailer.sample_email(@user).deliver 

      format.html { redirect_to @user, notice: 'User was successfully created.' } 
      format.json { render :show, status: :created, location: @user } 
     else 
      format.html { render :new } 
      format.json { render json: @user.errors, status: :unprocessable_entity } 
     end 
     end 
    end 

を送信するためのアプリがユーザーに電子メールを送信することはありません。

誰にも理由がありますか?

+1

LESS叫ん – tadman

+1

は、タイトルを変更してください* _ * –

+2

の質問 – bkunzi01

答えて

1

この回答は、私があなたがsendmailを使っているのを見ているので、あなたが無料のsendgrid AddonをHerokuから使用していることを前提としています。これを追加するには、herokuにログインし、無料のリソースとして追加します。電子メールをローカルまたはプロダクションで送信しようとしているかどうかを指定しなかったので、両方の設定を追加しました。あなたの設定/環境/ development.rbファイルでは、あなたの地元から送信するには、次の実行する必要があります。

config.action_mailer.delivery_method = :smtp #Yours used sendmail, change to this. 
    config.action_mailer.perform_deliveries = true #Needed if this is dev env. file 
    ActionMailer::Base.smtp_settings = { 
    :address  => 'smtp.sendgrid.net', 
    :port   => '587', 
    :authentication => :plain, 
    :user_name  => ENV['KUNZIG_SENDGRID_USERNAME'], 
    :password  => ENV['KUNZIG_SENDGRID_PASSWORD'], 
    :domain   => 'localhost:3000', 
    :enable_starttls_auto => true 
    } 

明らかに自分自身のENVでユーザー名とパスワードを交換してください。 Herokuによって割り当てられた変数。 Herokuの設定。 varsは設定タブの下にあります。 「公開」ボタンをクリックするだけです。あなたがアドオンとしてSengridを追加するときに、これらは、Herokuので自動的に設定されているので、唯一の変更は、ドメイン名と環境変数である

ActionMailer::Base.smtp_settings = { 
    :address  => 'smtp.sendgrid.net', 
    :port   => '587', 
    :authentication => :plain, 
    :user_name  => ENV['SENDGRID_USERNAME'], 
    :password  => ENV['SENDGRID_PASSWORD'], 
    :domain   => 'kunzig.herokuapp.com', 
    :enable_starttls_auto => true 
} 

お知らせ:

あなたの環境/ production.rbファイルが何かのようになります。また、コントローラーのdeliverコールをdeliver_nowに変更してください。バックグラウンドワーカーの設定に問題はないことがわかっています。

+0

heyyy更新configファイル –

+0

あなたはアプリをローカルでテストしていますか? – bkunzi01

+0

heroku :)これは稼働していて、ログにもエラーは表示されませんが、メールが届かない場合は、https://blooming-brushlands-80122.herokuapp.com/ –

関連する問題