2017-09-13 2 views
0

나는 레일 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

나는 레일 5, 적절한 구문이

UserNotifier.send_notification(user_notification, price).deliver_now

것 ... 그리고 이름으로 전체 이메일을 사용 믿습니다.

+0

소용돌이 치다하지만 아무것도하지 말라. 아직도 어떤 전자 우편도 receieve하지 말라. – Dave

+0

수정 사항이 추가되었습니다. Gmail을 릴레이로 사용하고 전체 이메일을 사용자 이름으로 사용했습니다. 그럴 가치가있어. –

+0

고마워, 나는 그것에 대해 생각하지 않았다. 나는 아직도 이메일을받지 못하고있다. (스팸에서도) - 무슨 일이 일어나고 있는지 추적 할 수있는 방법이 있는가? 로그 파일은별로 공개되지 않습니다. – Dave

관련 문제