2017-09-13 19 views
0

私はRails 5を使用していて、Gmailを中継器として使用している私の開発マシンからいくつかの電子メールを送信しようとしています。私は、このメーラーファイル、アプリ/メーラー/ user_notifier.rbGmailを使用してRailsからメールを送信するにはどうすればよいですか?

class UserNotifier < ActionMailer::Base 
    default from: RAILS_FROM_EMAIL 

    # send notification email to user about the price 
    def send_notification(user_notification, crypto_price) 
    puts "user notification: #{user_notification.id}" 
    @user = user_notification.user 
    @crypto_price = crypto_price 
    threshhold = user_notification.buy ? 'above' : 'below' 
    puts "user: #{@user.email} currency: #{@user.currency}" 
    mail(:to => @user.email, 
    :subject => sprintf(Constants::USER_NOTIFICATION_SUBJECT, crypto_price.crypto_currency.name, threshhold, PriceHelper.format_price(user_notification.price, @user.currency)) ) 
    end 

を持っていると私は私のログにエラーが表示されませんが、私はそう

UserNotifier.send_notification(user_notification, price).deliver 

ようSidekiq労働者からの電子メールを送信しますメールは配信されません(私は迷惑メールフォルダをチェックしてこれを確認しています)。以下は私のconfig/environments/development.rbファイルです。

# ActionMailer Config 
    config.action_mailer.smtp_settings = { 
    address:    'smtp.gmail.com', 
    port:     587, 
    domain:    'mybox.devbox.com', 
    user_name:   'myusertest1', 
    password:    'myuser99999', 
    authentication:  'plain', 
    enable_starttls_auto: true 
    } 
    config.action_mailer.delivery_method = :smtp 
    # change to true to allow email to be sent during development 
    config.action_mailer.perform_deliveries = true 
    config.action_mailer.raise_delivery_errors = true 
    config.action_mailer.default :charset => "utf-8" 

何が問題になる可能性がありますか、これをさらにトラブルシューティングする方法はありますか?

答えて

1

私はRailsの5で、適切な構文は

UserNotifier.send_notification(user_notification, price).deliver_now

だろう...と、ユーザー名として完全な電子メールを使用すると信じています。

+0

旋風を与えても何もしません。まだメールを受信して​​いない。 – Dave

+0

編集を追加しました。私はリレーとしてGmailを使用し、私は完全な電子メールをユーザー名として使用しました。試してみる価値。 –

+0

ありがとう、私はそれを考えなかった。私はまだメールを受け取っていません(迷惑メールでさえ) - 何が起こっているのかを知る方法はありますか?ログファイルはあまり明らかにならないようです。 – Dave

関連する問題