2014-12-02 9 views
1

메일 "에서"에서하지 설정 SMTP 사용자 이름에서 보내는 얻는다 ActionMailer의 방법은 user_mailer.rb에서

class UserMailer < ActionMailer::Base 
    default from: "[email protected]" 
    def approved_mail(user) 
    @user = user 
    @greeting = "Hi" 

    mail to: @user.email 
    end 
end 

그리고 development.rb에서

config.action_mailer.smtp_settings = { 
    address: "smtp.gmail.com", 
    port: 587, 
    domain: "gmail.com", 
    authentication: "plain", 
    enable_starttls_auto: true, 
    user_name: "[email protected]", 
    password: ENV["GMAIL_PASSWORD"] 
} 

내가 email.2 "에서 이메일을 레일 @ gmail.com "왜"[email protected] "에서 왔는지, 명확한 사람들을 기다리고 있습니다.

답변

2

smtp_settings, 우리는 우리의 메일 서버에 인증이 필요한 경우 user_namepassword를 설정해야합니다.

경우에 따라 '[email protected]'에 대한 인증을 development.rb 파일에 입력해야합니다. 따라서 액션 메일러는 인증 할 수 없으므로 default from: "[email protected]"을 무시합니다.

+0

은 user_mailer.rb의 'from'옵션에서 'smtp_settings> user_name'이 같아야 함을 의미합니다. 내 의견이 사실인지 충분한 이해가 부족합니다. – roarfromror

+0

네가 맞습니다. – Waleed

1

user_namesmtp_settings은 SMTP 서버에 연결하는 데 사용되는 인증 이름만을 나타냅니다.

development.rb이 추가 :

config.action_mailer.default_options = { from: "[email protected]" } 
+0

해결책 주셔서 감사합니다.하지만 user_mailer.rb에 지정된 주소에서 전자 메일을 받았으므로 user_mailer.rb의 'default from : "[email protected]"이 왜 작동하지 않는지 알고 싶습니다. – roarfromror